Module: TeXML
- Defined in:
- lib/texml.rb
Defined Under Namespace
Classes: CmdNode, CtrlNode, EnvNode, GroupNode, Node, OptNode, ParmNode, SpecNode, TexmlNode, TextNode
Constant Summary collapse
- SPECIAL_CHAR_ESCAPES =
Escaping sequences for LaTeX special characters
{ '%'[0] => '\%{}', '{'[0] => '\{', '}'[0] => '\}', '|'[0] => '$|${}', '#'[0] => '\#{}', '_'[0] => '\_{}', '^'[0] => '\\char`\\^{}', '~'[0] => '\\char`\\~{}', '&'[0] => '\&{}', '$'[0] => '\${}', #' '<'[0] => '$<${}', #' '>'[0] => '$>${}', #' '\\'[0] => '$\\backslash${}'#' }
- NODE_HANDLERS =
Keeps track of which classes can handle which type of nodes
Hash.new
Class Method Summary collapse
-
.convert(xml) ⇒ Object
Converts a TeXML document, passed as a raw XML string, into the corresponding (La)TeX document.
-
.quote(str) ⇒ Object
Given a raw string, returns a copy with all (La)TeX special characters properly quoted.
Class Method Details
.convert(xml) ⇒ Object
Converts a TeXML document, passed as a raw XML string, into the corresponding (La)TeX document.
8 9 10 11 |
# File 'lib/texml.rb', line 8 def TeXML.convert(xml) document = Nokogiri::XML(xml) TeXML::Node.create(document.root).to_tex end |
.quote(str) ⇒ Object
Given a raw string, returns a copy with all (La)TeX special characters properly quoted.
32 33 34 35 36 37 38 |
# File 'lib/texml.rb', line 32 def TeXML.quote(str) tex = '' str.each_byte do |char| tex << (SPECIAL_CHAR_ESCAPES[char] or char) end return tex end |