Class: Coradoc::Input::HTML::Converters::Math

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/input/html/converters/math.rb

Instance Method Summary collapse

Methods inherited from Base

#extract_leading_trailing_whitespace, #extract_title, #node_has_ancestor?, #textnode_after_start_with?, #textnode_before_end_with?, #treat, #treat_children, #treat_children_coradoc, #treat_coradoc, #unconstrained_after?, #unconstrained_before?

Instance Method Details

#convert(node, _state = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/coradoc/input/html/converters/math.rb', line 15

def convert(node, _state = {})
  stem = node.to_s.gsub(/\n/, " ")
  stem = MathML2AsciiMath.m2a(stem) if Coradoc::Input::HTML.config.mathml2asciimath
  unless stem.nil?
    stem = stem.gsub(/\[/, "\\[").gsub(/\]/, "\\]").gsub(
      /\(\(([^\)]+)\)\)/, "(\\1)"
    )
  end

  # TODO: This is to be done in Coradoc
  " stem:[" << stem << "] "
end

#to_coradoc(node, state = {}) ⇒ Object

FIXIT



11
12
13
# File 'lib/coradoc/input/html/converters/math.rb', line 11

def to_coradoc(node, state = {})
  convert(node, state)
end