Adds KaTeX math engine via the 'katex' ruby gem#489
Conversation
21104b4 to
9cae595
Compare
|
I have merged the proposed fix by @glebm to SsKaTeX and made a new release (no longer needs to overwrite |
|
I've updated the PR to trigger a test re-run |
50dc1b4 to
dbb46ba
Compare
|
The pre-2.3 targets are failing because the @gettalong Perhaps kramdown could drop official support for older rubies by removing them from |
|
You may have to constrain the |
|
For earlier rubies, the load failure would be reflected in the
|
b2c6794 to
3e73fb1
Compare
|
Thanks @ccorn, I've done as you suggested and Travis is now green |
|
So @glebm, could you explain to me what this implementation offers over sskatex? |
|
@gettalong The See also the discussion at ccorn/sskatex#1 |
|
From my point of view:
Let me add that KaTeX version control is important; e.g. in recent releases the handling of |
|
In Anyway, to avoid repeating that criterion too often, the |
|
@glebm If it is only that, then there is no real reason to add this to kramdown. If there were any big features that katex has but sskatex hasn't, than it would make sense. But from kramdown's point of view it doesn't make sense to provide two ways to do effectively the same. |
|
The workings and outputs are indeed almost the same (if the underlying KaTeX versions are the same), almost because SsKaTeX escapes non-ASCII characters passing to and from the engine. But the target user sets are disjoint: untrusted users on a github-pages-like service vs trusted individuals with their own specific setups. It solves the security issue discussed in #471 by bundling all the ingredients and binding the associated maintenance costs to the (I fear that some cloud service provider with unsecured kramdown setup will come complaining that his platform spent most of its computing power in horribly inefficient bitcoin mining. In that case, it would be good to be able to say not only RTFM but that there is a secure KaTeX alternative.) |
| - gem install rake | ||
| - gem install minitest coderay stringex ritex execjs sskatex | ||
| - > | ||
| ruby -e 'exit RUBY_VERSION < "2.3" ? 0 : 1' || gem install katex -v 0.3.0 |
There was a problem hiding this comment.
Please put this on one line, there is no need for splitting it across two.
There was a problem hiding this comment.
It contains a :. Do you know how it should be escaped if it's on one line?
There was a problem hiding this comment.
Figured it out, done.
There was a problem hiding this comment.
Hm... always something new to learn 👍 You are correct, the colon poses a problem, sorry. So leave that as it is.
| @@ -0,0 +1,29 @@ | |||
| --- | |||
There was a problem hiding this comment.
Please reformat the documentation to 100 columns. And you also need to link to this page on the documentation.page.
| configurable(:math_engine) | ||
|
|
||
| ['Mathjax', "MathjaxNode", "SsKaTeX", "Ritex", "Itex2MML"].each do |klass_name| | ||
| %w(Mathjax MathjaxNode Katex SsKaTeX Ritex Itex2MML).each do |klass_name| |
There was a problem hiding this comment.
Please just add your mathe engine here. No need to change the styling.
There was a problem hiding this comment.
It then does not fit on one line. How do you want it indented if it's split across multiple lines?
There was a problem hiding this comment.
Nevermind, from looking at other code I see that the undocumented column limit is not 80.
There was a problem hiding this comment.
Column limit is 100. When I have some more time I will add support for a linting tool...
|
|
||
| def self.call(converter, el, opts) | ||
| display_mode = el.options[:category] == :block | ||
| result = ::Katex.render el.value, |
There was a problem hiding this comment.
This method call is missing parentheses.
There was a problem hiding this comment.
Parenthesis are optional here. Do you have a style guide / a lint command to make sure I haven't missed anything else?
There was a problem hiding this comment.
No, not for kramdown. I would just use them here.
| end | ||
|
|
||
| KATEX_AVAILABLE = begin | ||
| SSKATEX_AVAILABLE = begin |
There was a problem hiding this comment.
The following lines should be indented two additional spaces since SSKATEX_AVAILABLE is two characters longer than KATEX_AVAILABLE.
|
|
The sources
I'd provide one in a follow-up PR if you do not want to touch SsKaTeX parts. In two rough sentences: Use |
|
@ccorn I've addressed your comments.
I'm going to take you up on this, thank you. |
|
In |
|
@ccorn I've added a link to the Assets section in the gem's docs to avoid duplicating any specifics here, because they may get out of date. For example, as Jekyll is a common use case, I'd like to support Automatic Registration for Jekyll in the future as well, if possible. Aside: if you use jekyll-assets, then automatic registration works (Sprockets without Rails case). |
|
Just mentioning that there are no Rdoc comments in |
|
IMHO, this PR (checked up to 4216c67) now has all required ingredients. |
|
@glebm Thanks for all the work - please squash the commits into one and rebase on current master, then I will merge. Thanks for your contribution! |
This is a simpler all batteries included alternative to the `sskatex` engine.
|
@gettalong Done! |
|
@glebm Thanks - I have merged the commit. |
This is a simpler all batteries included alternative to the
sskatexengine.