Module: MathML::Util

Included in:
SimpleLaTeX
Defined in:
lib/math_ml/util.rb

Defined Under Namespace

Classes: MathData, SimpleLaTeX

Constant Summary collapse

ESCAPES =
{ '<' => 'lt',
'>' => 'gt',
'&' => 'amp',
'"' => 'quot',
"'" => 'apos' }
INVALID_RE =
/(?!)/
EQNARRAY_RE =
/\\begin\s*\{eqnarray\}(#{MathML::LaTeX::MBEC}*?)\\end\s*\{eqnarray\}/
SINGLE_COMMAND_RE =
/(\\([a-zA-Z]+))[ \t]?/

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.collect_regexp(a) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/math_ml/util.rb', line 30

def self.collect_regexp(a)
  if a
    a = [a].flatten
    if a.size > 0
      Regexp.new(a.inject('') { |r, i| i.is_a?(Regexp) ? "#{r}#{i}|" : r }.chop)
    else
      INVALID_RE
    end
  else
    INVALID_RE
  end
end

.escapeXML(s, br = false) ⇒ Object



21
22
23
24
# File 'lib/math_ml/util.rb', line 21

def self.escapeXML(s, br = false)
  r = s.gsub(/[<>&"']/) { |m| "&#{ESCAPES[m]};" }
  br ? r.gsub(/\n/, "<br />\n") : r
end

Instance Method Details

#collect_regexp(a) ⇒ Object



43
44
45
# File 'lib/math_ml/util.rb', line 43

def collect_regexp(a)
  MathML::Util.collect_regexp(a)
end

#escapeXML(s, br = false) ⇒ Object



26
27
28
# File 'lib/math_ml/util.rb', line 26

def escapeXML(s, br = false)
  MathML::Util.escapeXML(s, br)
end