Class: MathML::LaTeX::Parser
Defined Under Namespace
Classes: CircularReferenceCommand
Constant Summary
collapse
- BUILTIN_MACRO =
<<'EOS'
\newenvironment{smallmatrix}{\begin{matrix}}{\end{matrix}}
\newenvironment{pmatrix}{\left(\begin{matrix}}{\end{matrix}\right)}
\newenvironment{bmatrix}{\left[\begin{matrix}}{\end{matrix}\right]}
\newenvironment{Bmatrix}{\left\{\begin{matrix}}{\end{matrix}\right\}}
\newenvironment{vmatrix}{\left|\begin{matrix}}{\end{matrix}\right|}
\newenvironment{Vmatrix}{\left\|\begin{matrix}}{\end{matrix}\right\|}
EOS
BuiltinCommands::Delimiters, BuiltinCommands::OVERS, BuiltinCommands::SymbolCommands, BuiltinCommands::UNDERS
MBEC
Instance Attribute Summary collapse
Instance Method Summary
collapse
#cmd_backslash, #cmd_entity, #cmd_frac, #cmd_hat_etc, #cmd_it_etc, #cmd_mathit_etc, #cmd_mbox, #cmd_quad_etc, #cmd_sqrt, #cmd_stackrel, #cmd_underbrace_etc
#add_environment, #grp_begin, #grp_left_etc
#env_array, #env_array_row, #env_matrix, #env_matrix_row
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
|
# File 'lib/math_ml.rb', line 616
def initialize
@unsecure_entity = false
@entities = Hash.new
@commands = Hash.new
@symbols = Hash.new
@delimiters = Array.new
@group_begins = Hash.new
@group_ends = Hash.new
@macro = Macro.new
@macro.parse(BUILTIN_MACRO)
@expanded_command = Array.new
@expanded_environment = Array.new
super
end
|
Instance Attribute Details
#macro ⇒ Object
Returns the value of attribute macro.
615
616
617
|
# File 'lib/math_ml.rb', line 615
def macro
@macro
end
|
#unsecure_entity ⇒ Object
Returns the value of attribute unsecure_entity.
614
615
616
|
# File 'lib/math_ml.rb', line 614
def unsecure_entity
@unsecure_entity
end
|
Instance Method Details
#add_commands(*a) ⇒ Object
663
664
665
666
667
668
669
|
# File 'lib/math_ml.rb', line 663
def add_commands(*a)
if a.size==1 && Hash===a[0]
@commands.merge!(a[0])
else
a.each{|i| @commands[i] = false}
end
end
|
#add_delimiter(list) ⇒ Object
679
680
681
|
# File 'lib/math_ml.rb', line 679
def add_delimiter(list)
@delimiters.concat(list)
end
|
#add_entity(list) ⇒ Object
632
633
634
635
636
|
# File 'lib/math_ml.rb', line 632
def add_entity(list)
list.each do |i|
@entities[i] = true
end
end
|
#add_group(begin_name, end_name, method = nil) ⇒ Object
683
684
685
686
|
# File 'lib/math_ml.rb', line 683
def add_group(begin_name, end_name, method=nil)
@group_begins[begin_name] = method
@group_ends[end_name] = begin_name
end
|
#add_multi_command(m, *a) ⇒ Object
671
672
673
|
# File 'lib/math_ml.rb', line 671
def add_multi_command(m, *a)
a.each{|i| @commands[i] = m}
end
|
#add_plugin(plugin) ⇒ Object
659
660
661
|
# File 'lib/math_ml.rb', line 659
def add_plugin(plugin)
self.extend(plugin)
end
|
#add_sym_cmd(hash) ⇒ Object
675
676
677
|
# File 'lib/math_ml.rb', line 675
def add_sym_cmd(hash)
@symbols.merge!(hash)
end
|
#parse(src, displaystyle = false) ⇒ Object
638
639
640
641
642
643
644
645
646
|
# File 'lib/math_ml.rb', line 638
def parse(src, displaystyle=false)
@ds = displaystyle
begin
parse_into(src, Math.new(@ds), Font::NORMAL)
rescue ParseError => e
e.done = src[0...(src.size - e.rest.size)]
raise
end
end
|
#push_container(container, scanner = @scanner, font = @font) ⇒ Object
648
649
650
651
652
653
654
655
656
657
|
# File 'lib/math_ml.rb', line 648
def push_container(container, scanner=@scanner, font=@font)
data = [@container, @scanner, @font]
@container, @scanner, @font = [container, scanner, font]
begin
yield container
container
ensure
@container, @scanner, @font = data
end
end
|