Giter Club home page Giter Club logo

asciimath's Introduction

AsciiMath

An AsciiMath parser and MathML generator written in pure Ruby.

Status

Linux Build Status Gem Version

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 or HTML (experimental.

math_ml = parsed_expression.to_mathml
html = parsed_expression.to_html

The MathML or HTML code is returned as a String.

Command line

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

MathML Generation
asciimath "an asciimath string"

or

asciimath mathml "an asciimath string"
HTML Generation
asciimath html "an asciimath string"

This command will print out the generated code on stdout.

Notes on the HTML Output

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.

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

asciimath's People

Contributors

pepijnve avatar tobski avatar whitphx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.