Add this line to your application’s Gemfile:
gem 'asciimath'
And then execute:
$ bundle
Or install it yourself as:
$ gem install asciimath
First require the library.
require 'asciimath'
Then parse an AsciiMath string.
parsed_expression = AsciiMath.parse(asciimath)
The parsed expression is a set of nested Array and Hash objects.
This expression can then be converted to MathML or HTML (experimental.
math_ml = parsed_expression.to_mathml
html = parsed_expression.to_html
The MathML or HTML code is returned as a String.
The HTML output is still regarded somewhat experimental - for basic usage it is fine, but it is not yet complete. Known issues are as follows:
-
sqrt
function does not generate sane output -
Use of font commands (e.g.
bb
) will result in broken output. -
Accents do not extend to match what they cover.
-
Rendering of "integrals" uses a generic path that does not look amazing.
-
The size of braces does not account for complex content - so a matrix will render with the right sized braces if all of its elements are single-height text, but braces around e.g. fractions will render at the incorrect height.
Rendering the HTML output correctly requires the inclusion of style/math.css
in the html document.
There is currently no specific required font for this output, it simply selects a serif
font family - change the @font-family
attribute in the .math-inline
class to select something specific.
-
Create your feature branch (
git checkout -b my-new-feature
) -
Commit your changes (
git commit -am 'Add some feature'
) -
Push to the branch (
git push origin my-new-feature
) -
Create a new Pull Request