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

Pre-render KaTeX and highlight #107

Closed
tlienart opened this issue Mar 24, 2019 · 5 comments
Closed

Pre-render KaTeX and highlight #107

tlienart opened this issue Mar 24, 2019 · 5 comments
Labels
enhancement New feature or request wip

Comments

@tlienart
Copy link
Owner

This may require a fair bit of work to function but could lead to a removal of requiring the katex.js and highlight.js by just doing everything locally (pre-rendering to HTML) before it's pushed which would lead to even faster pages.

@tlienart tlienart added enhancement New feature or request brainstorm katex labels Mar 24, 2019
@tlienart
Copy link
Owner Author

tlienart commented Mar 25, 2019

Katex

var katex = require("./libs/katex/katex.min.js")
var html = katex.renderToString("x^2 + \\exp(x) - 1 = 0", {
  displayMode: true});
console.log(html)

Note there seems to be a difference between 0.9 and 0.10, doesn't lead to the same output.

@tlienart tlienart added the wip label Apr 12, 2019
@tlienart
Copy link
Owner Author

Status update

  • KaTeX pre-rendering works on branch prerender
  • Will try using it fully on my own website to see if all ok
  • It's a bit slow so should not be used in a continuous serve context, rather it should be used in a single-pass along with the minification. One of the reason is that node has to be called for every single math element, and so may be fired dozens of time on a single page

The last issue may be mitigated quite a bit if instead of firing node in the markdown conversion, we do it in the html conversion, in that case it may be somewhat easier to find all math blocks in one shot and fire node just once per page.

@tlienart
Copy link
Owner Author

The second version (conversion directly in the HTML) is implemented on branch prerender2, will experiment a bit and pick one and then use the same modus operandi for highlights.js

@tlienart
Copy link
Owner Author

tlienart commented Apr 16, 2019

Update:

@tlienart
Copy link
Owner Author

now done and applied on personal website, works great.

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

No branches or pull requests

1 participant