An AsciiMath parser and MathML generator written in pure Ruby.

Installation

Add this line to your application’s Gemfile:

gem 'asciimath'

And then execute:

$ bundle

Or install it yourself as:

$ gem install asciimath

Usage

Library

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.

math_ml = parsed_expression.to_mathml

The MathML code is returned as a String.

Command line

The AsciiMath parser and MathML converter can be invoked via the command line as follows:

asciimath "an asciimath string"

This command will print out the generated MathML code on stdout.

Contributing

  1. Fork it (https://github.com/pepijnve/asciimath/fork)

  2. Create your feature branch (git checkout -b my-new-feature)

  3. Commit your changes (git commit -am 'Add some feature')

  4. Push to the branch (git push origin my-new-feature)

  5. Create a new Pull Request