ccorn / sskatex

SsKaTeX - Server-side KaTeX for Ruby
MIT License
0 stars 1 forks source link

FYI: the katex gem #1

Open glebm opened 6 years ago

glebm commented 6 years ago

Hi! I needed server-side KaTeX in Ruby a while ago and maintain this gem: https://github.com/glebm/katex-ruby (predates sskatex by about 10 months).

It has some differences: the assets are bundled with the gem (allowing for a simpler API), and Rails is supported out of the box.

I also use my gem with kramdown (for Thredded): https://github.com/thredded/thredded-markdown_katex/blob/master/lib/thredded/markdown_katex/kramdown/katex_converter.rb

ccorn commented 6 years ago

Interesting! Some remarks:

glebm commented 6 years ago

I agree with all the remarks but this one:

On the other hand, that takes control of the KaTeX version away from users. Upgrading katex.js can introduce incompatible changes like the handling of \color which can change the output in a significant way. Users need a way to control that.

The user can control this by choosing the appropriate gem version, assuming all KaTeX releases have a corresponding gem release.

ccorn commented 6 years ago

Perhaps a best of both worlds approach would be to bundle KaTeX while also allowing the user to specify a different JS file at initialization. I'll look into adding this to the katex gem.

Note that adding such an option necessitates security considerations and hardening efforts. Which is why I recommend against installation of the SsKaTeX gem for kramdown as long as the configuration can be changed by untrusted users. Your bundling of KaTeX has the advantage that no JS injection points need to be exposed. You might want to keep it that way.

glebm commented 6 years ago

You're right. Also for a motivated user it is easy to fork the gem and run rake update[v1.2.3] if they need a different version.