KaTeX on Rails
Convert LaTeX math formulas to HTML using KaTeX in Rails.
KaTeX on Rails uses Nodo to call the KaTex Node.js package.
Installation
Add the KaTeX on Rails gem:
bundle add katex_on_rails
Or add this line to your Gemfile manually:
gem 'katex_on_rails'
Install the katex
package with npm
:
npm install katex
Or with yarn
:
yarn add katex
To render any HTML generated by this gem, you will need to link the CSS file
from the katex
Node.js package, make the KaTeX font files available to the client,
and use the HTML5 doctype. See browser usage.
Note, however, that you do not need to include katex.js
on the client.
Usage
katex = KatexOnRails.new
katex.render_to_string('x', { output: 'html' })
#=> "<span class=\"katex\">..."
The last argument to render_to_string
can contain a variety of rendering options.
License
The KaTeX on Rails gem is is released under the MIT License.