Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About client-side katex.js features #109

Closed
rogeryoungh opened this issue Mar 11, 2024 · 2 comments · Fixed by #110
Closed

About client-side katex.js features #109

rogeryoungh opened this issue Mar 11, 2024 · 2 comments · Fixed by #110
Labels
enhancement New feature or request

Comments

@rogeryoungh
Copy link
Contributor

I'm trying to remove the katex-rs dependency in mdbook-katex based on escape trick. I escaped three characters: \->\\ * -> \* _ -> \_. So far, I haven't found any problems.

I've noticed that the main repository is having a lot of problems with quickjs, so maybe we should add client-js mode. Thanks to the good design of scan, I can easily merge my escape code using the cargo feature.

I have only tested the case where KatexConfig is the default setting and it works fine on my site.

for c in code.chars() {
    match c {
        '_' => {
            result.push_str("\\_");
        }
        '*' => {
            result.push_str("\\*");
        }
        '\\' => {
            result.push_str("\\\\");
        }
        _ => {
            result.push(c);
        }
    }
}

Currently I am experiencing the following issues:

  • The katex.css is added to the HTML by the preprocessor. To add katex.js we also need to generate the configuration using the auto-render.js hook according to KatexConfig.
  • The KatexConfig configuration is very extensive and I'm not sure which configurations are broken by the client-side js mode.
  • I think it might be easier to instruct people to use head.hbs in the README.
@SichangHe SichangHe added the enhancement New feature or request label Mar 11, 2024
@SichangHe
Copy link
Collaborator

Sounds good. We could put katex-rs behind a feature flag, and it would get rid of a slew of problems from it for some people.
It would need to be a default feature for backwards compatibility, though.

I have only tested the case where KatexConfig is the default setting and it works fine on my site.

Please provide a dummy example in the README for people's reference. This feature would be experimental, and people would try it out at their own risks following the dummy example.

  • The katex.css is added to the HTML by the preprocessor. To add katex.js we also need to generate the configuration using the auto-render.js hook according to KatexConfig.
  • The KatexConfig configuration is very extensive and I'm not sure which configurations are broken by the client-side js mode.
  • I think it might be easier to instruct people to use head.hbs in the README.

I think we let people configure this themselves in the template, because it is client-side. KatexConfig is for server-side rendering.
Note that the no-css option could also be set, if the user wants to set katex.css themselves.

@SichangHe
Copy link
Collaborator

Please feel free to ask any questions that would help you implement this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants