Class: MathML::LaTeX::Parser
Defined Under Namespace
Classes: CircularReferenceCommand
Constant Summary
collapse
- BUILTIN_MACRO =
"\\newenvironment{smallmatrix}{\\begin{matrix}}{\\end{matrix}}\n\\newenvironment{pmatrix}{\\left(\\begin{matrix}}{\\end{matrix}\\right)}\n\\newenvironment{bmatrix}{\\left[\\begin{matrix}}{\\end{matrix}\\right]}\n\\newenvironment{Bmatrix}{\\left\\{\\begin{matrix}}{\\end{matrix}\\right\\}}\n\\newenvironment{vmatrix}{\\left|\\begin{matrix}}{\\end{matrix}\\right|}\n\\newenvironment{Vmatrix}{\\left\\|\\begin{matrix}}{\\end{matrix}\\right\\|}\n"
BuiltinCommands::OVERS, 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(opt = {}) ⇒ Parser
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
|
# File 'lib/math_ml/latex.rb', line 375
def initialize(opt = {})
@unsecure_entity = false
@entities = {}
@commands = {}
@symbols = {}
@delimiters = []
@group_begins = {}
@group_ends = {}
@macro = Macro.new
@macro.parse(BUILTIN_MACRO)
@expanded_command = []
@expanded_environment = []
@symbol_table = opt[:symbol] || MathML::Symbol::Default
@symbol_table = MathML::Symbol::MAP[@symbol_table] if @symbol_table.is_a?(::Symbol)
super()
end
|
Instance Attribute Details
#macro ⇒ Object
Returns the value of attribute macro.
373
374
375
|
# File 'lib/math_ml/latex.rb', line 373
def macro
@macro
end
|
#symbol_table ⇒ Object
Returns the value of attribute symbol_table.
373
374
375
|
# File 'lib/math_ml/latex.rb', line 373
def symbol_table
@symbol_table
end
|
#unsecure_entity ⇒ Object
Returns the value of attribute unsecure_entity.
372
373
374
|
# File 'lib/math_ml/latex.rb', line 372
def unsecure_entity
@unsecure_entity
end
|
Instance Method Details
#add_commands(*a) ⇒ Object
426
427
428
429
430
431
432
|
# File 'lib/math_ml/latex.rb', line 426
def add_commands(*a)
if a.size == 1 && a[0].is_a?(Hash)
@commands.merge!(a[0])
else
a.each { |i| @commands[i] = false }
end
end
|
#add_delimiter(list) ⇒ Object
442
443
444
|
# File 'lib/math_ml/latex.rb', line 442
def add_delimiter(list)
@delimiters.concat(list)
end
|
#add_entity(list) ⇒ Object
393
394
395
396
397
|
# File 'lib/math_ml/latex.rb', line 393
def add_entity(list)
list.each do |i|
@entities[i] = true
end
end
|
#add_group(begin_name, end_name, method = nil) ⇒ Object
446
447
448
449
|
# File 'lib/math_ml/latex.rb', line 446
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
434
435
436
|
# File 'lib/math_ml/latex.rb', line 434
def add_multi_command(m, *a)
a.each { |i| @commands[i] = m }
end
|
#add_plugin(plugin) ⇒ Object
422
423
424
|
# File 'lib/math_ml/latex.rb', line 422
def add_plugin(plugin)
extend(plugin)
end
|
#add_sym_cmd(hash) ⇒ Object
438
439
440
|
# File 'lib/math_ml/latex.rb', line 438
def add_sym_cmd(hash)
@symbols.merge!(hash)
end
|
#parse(src, displaystyle = false) ⇒ Object
399
400
401
402
403
404
405
406
407
|
# File 'lib/math_ml/latex.rb', line 399
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
409
410
411
412
413
414
415
416
417
418
419
420
|
# File 'lib/math_ml/latex.rb', line 409
def push_container(container, scanner = @scanner, font = @font)
data = [@container, @scanner, @font]
@container = container
@scanner = scanner
@font = font
begin
yield container
container
ensure
@container, @scanner, @font = data
end
end
|