Sha256: 641d4bf9439a2b58625965ba6813910ed26889bbd7eec8a833443cc68ffebbde

Contents?: true

Size: 655 Bytes

Versions: 2

Compression:

Stored size: 655 Bytes

Contents

require "hemingway/math/math_nodes"

module Hemingway
  grammar Math

    # Example: $ \Pi = 3.14159 $
    rule math
      math_start content:( symbol / exponent ) math_end <MathNode>
    end

    # Example : \Pi
    # Notes:
    #  - Once again, math_symbol need not have an html method defined on it.
    #  When .html is called on symbol, it knows the match is actually a
    #  math_symbol, so that is what symbol.html is actually calling.
    rule symbol
      math_symbol
    end

    rule exponent
      "^{" value:( "\\circ" / text ) "}" <ExponentNode>
    end

    rule math_start
      "$"
    end

    rule math_end
      "$"
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hemingway-1.0.0 lib/hemingway/math/math.treetop
hemingway-0.0.3 lib/hemingway/math/math.treetop