glebm / katex-ruby

Renders KaTeX from Ruby.
MIT License
24 stars 10 forks source link

Auto render Katex #9

Open enaguero opened 2 years ago

enaguero commented 2 years ago

First of all, thank you for creating this initiative! It looks the most promising for our the ruby/rails environment. I am looking forward to see if there is any option to use the auto-render extension or if there any plan to built one in ruby. My main problem using Katex with a possible auto-render alternative is finding the appropriate regex to identify all the possible LATEX code in a given string.

Any guidance how I could accomplish this would be appreciated. In case there is not such a possibility, I am more than happy to start a possible collaboration to include this option in katex-ruby.

glebm commented 2 years ago

to use the auto-render extension

This gem is for rendering KaTeX server-side. The auto-render extension in KaTeX is for client side rendering. If you want to render client-side, you can just use the KaTeX npm package directly.

If you use markdown and want to render client-side, you can use this Kramdown plugin https://github.com/kramdown/math-katex

enaguero commented 2 years ago

@glebm, thank you for your feedback. I am not a native English speaker, so maybe my question was not very clear; sorry about that. However, I wonder if we could create an option where Katex receives a text string with several latex strings (inline or not), and it's converted to HTML on the server-side like:

text_to_html = "Here is the equation $c = \\pm\\sqrt{a^2 + b^2}$, please compare the result with $x = sqrt{a^2 + b^2}$" 
Katex.render text_to_html

I hope my doubt or initiative is more explicit.