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

Replace MathJax with KaTeX #1669

Closed
wants to merge 11 commits into from
Closed

Replace MathJax with KaTeX #1669

wants to merge 11 commits into from

Conversation

ralsina
Copy link
Member

@ralsina ralsina commented Apr 24, 2015

Not for merging, of course, but hey, let's play with it.

@Kwpolska
Copy link
Member

What happened to the bootstrap theme?!

@ralsina
Copy link
Member Author

ralsina commented Apr 24, 2015

Now that is what happens when you use jinjify wrong

@Kwpolska
Copy link
Member

now please fix the bootstrap theme (restore it to the way it is on master and patch for katex)

Also, you can now just type scripts/jinjify.py and it will do all the thinking for you.

@ralsina
Copy link
Member Author

ralsina commented Apr 24, 2015

done. This works for delimited math like using $$foo+bar$$ directly but doesn't pick up :math:'foo+bar' or the math directive, that needs extra thinking.

@Kwpolska
Copy link
Member

We might need some special config for the auto-render plugin.

@ralsina
Copy link
Member Author

ralsina commented Apr 24, 2015

Now it works for math role but not for math directive for reasons I don't know.
Also, it has to iterate over all elements with math class, so base is broken because it has no JQuery and my JS sucks

@Kwpolska Kwpolska added this to the v7.3.2 milestone Apr 25, 2015
@Kwpolska
Copy link
Member

Your hacky patch is unnecessary. All we need to do is change the delimiters for auto-render. (also, you forgot the CSS)

For example:

<script>
renderMathInElement(document.body, {delimiters: [
  {left: "\\begin{equation*}", right: "\\end{equation*}", display: true},
  {left: "\\[", right: "\\]", display: true},
  {left: "\\(", right: "\\)", display: false}
]})
</script>

We should make those configurable via the config file, because some weird people really want dollars (deprecated and error-prone) as delimiters. We also need $latex…$ for WordPress.com converts.

I’ll work on this.

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
@Kwpolska Kwpolska changed the title q&d conversion to KaTeX Replace MathJax with KaTeX Apr 25, 2015
@Kwpolska
Copy link
Member

This should be quite functional now, and KaTeX is now fully bundled — an empty site grew from 2.5 MB to 3.8 MB) We still have a few references we might want to change.

We might also want to restore mathjax.js (without actually including it anywhere) for compatibility with old themes — @ralsina, any opinions?

cc @damianavila — do you know of any problems, other than having to upgrade all custom themes?

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
@damianavila
Copy link
Member

cc @damianavila — do you know of any problems, other than having to upgrade all custom themes?

Not sure, I did not play with katex before, the notebook uses Mathjax so maybe there is some degree of incompatibility... if there is a possibility, I would leave the mathjax support, at least, as an option...

@asmeurer
Copy link
Contributor

asmeurer commented May 3, 2015

Please don't make KaTeX the default. It has limited math support compared to mathjax (see KaTeX/KaTeX#43).

@ralsina ralsina modified the milestones: Whenever, v7.3.2 May 3, 2015
@ralsina
Copy link
Member Author

ralsina commented Jun 5, 2015

This won't happen because of KaTeX limitations.

@ralsina ralsina closed this Jun 5, 2015
@asmeurer
Copy link
Contributor

asmeurer commented Jun 5, 2015

It would be great to add KaTeX support, but make it an option alongside MathJax, and do it in a way that doesn't change existing sites unless you explicitly add something to conf.py (I don't personally care about the defaults for new sites).

@Kwpolska
Copy link
Member

Kwpolska commented Jun 6, 2015

It’s not easy to juggle two different systems. You can always add KaTeX to your own site via BODY_END and not using the mathjax tags.

Kwpolska added a commit that referenced this pull request Jun 6, 2015
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
@Kwpolska Kwpolska deleted the katex branch June 6, 2015 08:05
@przemoc
Copy link

przemoc commented Jul 23, 2015

It's worth to note that limitations in KaTeX are slowly vanishing. For instance v0.4.0 (released over a month ago):

Added support for some \begin/\end environments, including support for array, matrix, pmatrix, bmatrix, vmatrix, and Vmatrix

and v0.5.0 (released a week ago):

Add the cases and Bmatrix environments.

One day it may become good enough for becoming a default engine for math input in Nikola.

@Kwpolska
Copy link
Member

When that happens (and someone tells us about it!), we’ll happily include it. We are not qualified to tell it’s good or not…

@Kwpolska
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants