Module: MathML::LaTeX::BuiltinCommands
- Included in:
- Parser
- Defined in:
- lib/math_ml/latex.rb,
lib/math_ml/latex.rb
Constant Summary collapse
- OVERS =
{'hat'=>'circ', 'breve'=>'smile', 'grave'=>'grave', 'acute'=>'acute', 'dot'=>'sdot', 'ddot'=>'nldr', 'tilde'=>'tilde', 'bar'=>'macr', 'vec'=>'rightarrow', 'check'=>'vee', 'widehat'=>'circ', 'overline'=>'macr', 'widetilde'=>'tilde', 'overbrace'=>'OverBrace'}
- UNDERS =
{'underbrace'=>'UnderBrace', 'underline'=>'macr'}
Instance Method Summary collapse
- #cmd_backslash ⇒ Object
- #cmd_entity ⇒ Object
- #cmd_frac ⇒ Object
- #cmd_hat_etc ⇒ Object
- #cmd_it_etc ⇒ Object
- #cmd_mathit_etc ⇒ Object
- #cmd_mbox ⇒ Object
- #cmd_quad_etc ⇒ Object
- #cmd_sqrt ⇒ Object
- #cmd_stackrel ⇒ Object
- #cmd_underbrace_etc ⇒ Object
- #initialize ⇒ Object
Instance Method Details
#cmd_backslash ⇒ Object
724 725 726 |
# File 'lib/math_ml/latex.rb', line 724 def cmd_backslash @ds ? nil : XMLElement.new("br", "xmlns"=>"http://www.w3.org/1999/xhtml") end |
#cmd_entity ⇒ Object
738 739 740 741 742 743 744 745 746 747 |
# File 'lib/math_ml/latex.rb', line 738 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 ⇒ Object
804 805 806 807 |
# File 'lib/math_ml/latex.rb', line 804 def cmd_frac n = parse_any; d = parse_any Frac.new(n, d) end |
#cmd_hat_etc ⇒ Object
728 729 730 731 |
# File 'lib/math_ml/latex.rb', line 728 def cmd_hat_etc com = @scanner[1] Over.new(parse_any, Operator.new << entitize(OVERS[com])) end |
#cmd_it_etc ⇒ Object
773 774 775 776 777 778 779 780 781 782 783 |
# File 'lib/math_ml/latex.rb', line 773 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 ⇒ Object
785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 |
# File 'lib/math_ml/latex.rb', line 785 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 ⇒ Object
820 821 822 823 |
# File 'lib/math_ml/latex.rb', line 820 def cmd_mbox @scanner.scan_any Text.new << (@scanner.matched =~ RE::BLOCK ? @scanner[1] : @scanner.matched) end |
#cmd_quad_etc ⇒ Object
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 |
# File 'lib/math_ml/latex.rb', line 754 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 ⇒ Object
809 810 811 812 813 814 815 816 817 818 |
# File 'lib/math_ml/latex.rb', line 809 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 ⇒ Object
749 750 751 752 |
# File 'lib/math_ml/latex.rb', line 749 def cmd_stackrel o = parse_any; b = parse_any Over.new(b, o) end |
#cmd_underbrace_etc ⇒ Object
733 734 735 736 |
# File 'lib/math_ml/latex.rb', line 733 def cmd_underbrace_etc com = @scanner[1] Under.new(parse_any, Operator.new << entitize(UNDERS[com])) end |
#initialize ⇒ Object
710 711 712 713 714 715 716 717 718 719 720 721 722 |
# File 'lib/math_ml/latex.rb', line 710 def initialize add_commands("\\"=>:backslash) add_commands("entity", "stackrel", "frac", "sqrt", "mbox") add_multi_command(:hat_etc, 'hat', 'breve', 'grave', 'acute', 'dot', 'ddot', 'tilde', 'bar', 'vec', 'check', 'widehat', 'overline', 'widetilde', 'overbrace') add_multi_command(:underbrace_etc, 'underbrace', 'underline') 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 |