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



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

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

.escapeXML(s, br = false) ⇒ Object



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

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



40
41
42
# File 'lib/math_ml/util.rb', line 40

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

#escapeXML(s, br = false) ⇒ Object



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

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