# module MathML::LaTeX::BuiltinCommands

### Constants

OVERS
UNDERS

### Public Class Methods

new() click to toggle source
Calls superclass method

    # File lib/math_ml/latex.rb, line 711
    def initialize
            add_commands("\\"=>:backslash)
            add_commands("entity", "stackrel", "frac", "sqrt", "mbox")
            add_multi_command(:hat_etc, *OVERS.keys)
            add_multi_command(:underbrace_etc, *UNDERS.keys)
            add_multi_command(:quad_etc, " ", "quad", "qquad", ",", ":", ";", "!")
            add_multi_command(:it_etc, "it", "rm", "bf")
            add_multi_command(:mathit_etc, "mathit", "mathrm", "mathbf", "bm", "mathbb", "mathscr", "mathfrak")
            add_sym_cmd(Builtin::Symbol::MAP)
            add_delimiter(Builtin::Symbol::DELIMITERS)

            super
    end

### Public Instance Methods

cmd_backslash() click to toggle source

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

cmd_entity() click to toggle source

    # File lib/math_ml/latex.rb, line 739
    def cmd_entity
            param = @scanner.scan_block ? @scanner[1] : @scanner.scan(/./)
            raise ParseError.new("Need parameter.") unless param
            unless @unsecure_entity || @entities[param]
                    param =@scanner.matched[/\A\{#{RE::SPACE}*(.*\})\z/, 1] if @scanner.matched=~RE::BLOCK
                    @scanner.pos = @scanner.pos-(param.size)
                    raise ParseError.new("Unregistered entity.")
            end
            Operator.new << entitize(param)
    end

cmd_frac() click to toggle source

    # File lib/math_ml/latex.rb, line 805
    def cmd_frac
            n = parse_any; d = parse_any
            Frac.new(n, d)
    end

cmd_hat_etc() click to toggle source

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

cmd_it_etc() click to toggle source

    # File lib/math_ml/latex.rb, line 774
    def cmd_it_etc
            case @scanner[1]
            when 'it'
                    @font = Font::NORMAL
            when 'rm'
                    @font = Font::ROMAN
            when 'bf'
                    @font = Font::BOLD
            end
            nil
    end

cmd_mathit_etc() click to toggle source

    # File lib/math_ml/latex.rb, line 786
    def cmd_mathit_etc
            case @scanner[1]
            when 'mathit'
                    parse_mathfont(Font::NORMAL)
            when 'mathrm'
                    parse_mathfont(Font::ROMAN)
            when 'mathbf'
                    parse_mathfont(Font::BOLD)
            when 'bm'
                    parse_mathfont(Font::BOLD_ITALIC)
            when 'mathbb'
                    parse_mathfont(Font::BLACKBOLD)
            when 'mathscr'
                    parse_mathfont(Font::SCRIPT)
            when 'mathfrak'
                    parse_mathfont(Font::FRAKTUR)
            end
    end

cmd_mbox() click to toggle source

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

cmd_quad_etc() click to toggle source

    # File lib/math_ml/latex.rb, line 755
    def cmd_quad_etc
            case @scanner[1]
            when ' '
                    Space.new("1em")
            when 'quad'
                    Space.new("1em")
            when 'qquad'
                    Space.new("2em")
            when ','
                    Space.new("0.167em")
            when ':'
                    Space.new("0.222em")
            when ';'
                    Space.new("0.278em")
            when '!'
                    Space.new("-0.167em")
            end
    end

cmd_sqrt() click to toggle source

    # File lib/math_ml/latex.rb, line 810
    def cmd_sqrt
            if @scanner.scan_option
                    i = parse_into(@scanner[1], Array.new)
                    i = i.size==1 ? i[0] : (Row.new << i)
                    b = parse_any
                    Root.new(i, b)
            else
                    Sqrt.new << parse_any
            end
    end

cmd_stackrel() click to toggle source

    # File lib/math_ml/latex.rb, line 750
    def cmd_stackrel
            o = parse_any; b = parse_any
            Over.new(b, o)
    end

cmd_underbrace_etc() click to toggle source

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