# module MathML::LaTeX::BuiltinCommands

### Constants

OVERS
UNDERS

### Public Class Methods

new() click to toggle source
Calls superclass method

        # File lib/math_ml/latex.rb
    724 def initialize
    725   add_commands('\\' => :backslash)
    726   add_commands('entity', 'stackrel', 'frac', 'sqrt', 'mbox')
    727   add_multi_command(:hat_etc, *OVERS.keys)
    728   add_multi_command(:underbrace_etc, *UNDERS.keys)
    729   add_multi_command(:quad_etc, ' ', 'quad', 'qquad', ',', ':', ';', '!')
    730   add_multi_command(:it_etc, 'it', 'rm', 'bf')
    731   add_multi_command(:mathit_etc, 'mathit', 'mathrm', 'mathbf', 'bm', 'mathbb', 'mathscr', 'mathfrak')
    732   add_sym_cmd(Builtin::Symbol::MAP)
    733   add_delimiter(Builtin::Symbol::DELIMITERS)
    734
    735   super
    736 end

### Public Instance Methods

cmd_backslash() click to toggle source

        # File lib/math_ml/latex.rb
    738 def cmd_backslash
    739   @ds ? nil : XMLElement.new('br', 'xmlns' => 'http://www.w3.org/1999/xhtml')
    740 end

cmd_entity() click to toggle source

        # File lib/math_ml/latex.rb
    752 def cmd_entity
    753   param = @scanner.scan_block ? @scanner[1] : @scanner.scan(/./)
    754   raise ParseError, 'Need parameter.' unless param
    755
    756   unless @unsecure_entity || @entities[param]
    757     param = @scanner.matched[/\A\{#{RE::SPACE}*(.*\})\z/, 1] if @scanner.matched =~ RE::BLOCK
    758     @scanner.pos = @scanner.pos - param.size
    759     raise ParseError, 'Unregistered entity.'
    760   end
    761   Operator.new << entitize(param)
    762 end

cmd_frac() click to toggle source

        # File lib/math_ml/latex.rb
    820 def cmd_frac
    821   n = parse_any
    822   d = parse_any
    823   Frac.new(n, d)
    824 end

cmd_hat_etc() click to toggle source

        # File lib/math_ml/latex.rb
    742 def cmd_hat_etc
    743   com = @scanner[1]
    744   Over.new(parse_any, Operator.new << entitize(OVERS[com]))
    745 end

cmd_it_etc() click to toggle source

        # File lib/math_ml/latex.rb
    789 def cmd_it_etc
    790   case @scanner[1]
    791   when 'it'
    792     @font = Font::NORMAL
    793   when 'rm'
    794     @font = Font::ROMAN
    795   when 'bf'
    796     @font = Font::BOLD
    797   end
    798   nil
    799 end

cmd_mathit_etc() click to toggle source

        # File lib/math_ml/latex.rb
    801 def cmd_mathit_etc
    802   case @scanner[1]
    803   when 'mathit'
    804     parse_mathfont(Font::NORMAL)
    805   when 'mathrm'
    806     parse_mathfont(Font::ROMAN)
    807   when 'mathbf'
    808     parse_mathfont(Font::BOLD)
    809   when 'bm'
    810     parse_mathfont(Font::BOLD_ITALIC)
    811   when 'mathbb'
    812     parse_mathfont(Font::BLACKBOLD)
    813   when 'mathscr'
    814     parse_mathfont(Font::SCRIPT)
    815   when 'mathfrak'
    816     parse_mathfont(Font::FRAKTUR)
    817   end
    818 end

cmd_mbox() click to toggle source

        # File lib/math_ml/latex.rb
    837 def cmd_mbox
    838   @scanner.scan_any
    839   Text.new << (@scanner.matched =~ RE::BLOCK ? @scanner[1] : @scanner.matched)
    840 end

cmd_quad_etc() click to toggle source

        # File lib/math_ml/latex.rb
    770 def cmd_quad_etc
    771   case @scanner[1]
    772   when ' '
    773     Space.new('1em')
    774   when 'quad'
    775     Space.new('1em')
    776   when 'qquad'
    777     Space.new('2em')
    778   when ','
    779     Space.new('0.167em')
    780   when ':'
    781     Space.new('0.222em')
    782   when ';'
    783     Space.new('0.278em')
    784   when '!'
    785     Space.new('-0.167em')
    786   end
    787 end

cmd_sqrt() click to toggle source

        # File lib/math_ml/latex.rb
    826 def cmd_sqrt
    827   if @scanner.scan_option
    828     i = parse_into(@scanner[1], [])
    829     i = i.size == 1 ? i[0] : (Row.new << i)
    830     b = parse_any
    831     Root.new(i, b)
    832   else
    833     Sqrt.new << parse_any
    834   end
    835 end

cmd_stackrel() click to toggle source

        # File lib/math_ml/latex.rb
    764 def cmd_stackrel
    765   o = parse_any
    766   b = parse_any
    767   Over.new(b, o)
    768 end

cmd_underbrace_etc() click to toggle source

        # File lib/math_ml/latex.rb
    747 def cmd_underbrace_etc
    748   com = @scanner[1]
    749   Under.new(parse_any, Operator.new << entitize(UNDERS[com]))
    750 end