Bring up to current.

This commit is contained in:
Jacques Distler 2007-01-22 08:36:51 -06:00
parent 69b62b6f33
commit b19e1e4f47
71 changed files with 8305 additions and 39 deletions

View file

@ -0,0 +1,35 @@
module MaRuKu; module Out; module HTML
def convert_to_mathml_itex2mml(tex, method)
begin
if not $itex2mml_parser
require 'itextomml'
$itex2mml_parser = Itex2MML::Parser.new
end
mathml = $itex2mml_parser.send(method, tex)
doc = Document.new(mathml, {:respect_whitespace =>:all}).root
return doc
rescue LoadError => e
maruku_error "Could not load package 'itex2mml'.\n"+
"Please install it."
rescue REXML::ParseException => e
maruku_error "Invalid MathML TeX: \n#{add_tabs(tex,1,'tex>')}"+
"\n\n #{e.inspect}"
rescue
maruku_error "Could not produce MathML TeX: \n#{tex}"+
"\n\n #{e.inspect}"
end
nil
end
def to_html_inline_math_itex2mml
convert_to_mathml_itex2mml(self.math, :inline_filter)
end
def to_html_equation_itex2mml
convert_to_mathml_itex2mml(self.math, :block_filter)
end
end end end

View file

@ -0,0 +1,20 @@
module MaRuKu; module Out; module HTML
def to_html_inline_math_none
# You can: either return a REXML::Element
# return Element.new 'div'
# or return an empty array on error
# return []
# or have a string parsed by REXML:
tex = self.math
tex.gsub!('&','&')
mathml = "<code>#{tex}</code>"
return Document.new(mathml).root
end
def to_html_equation_none
return to_html_inline_math_none
end
end end end

View file

@ -0,0 +1,34 @@
module MaRuKu; module Out; module HTML
def convert_to_mathml_ritex(tex)
begin
if not $ritex_parser
require 'ritex'
$ritex_parser = Ritex::Parser.new
end
mathml = $ritex_parser.parse(tex.strip)
doc = Document.new(mathml, {:respect_whitespace =>:all}).root
return doc
rescue LoadError => e
maruku_error "Could not load package 'ritex'.\n"+
"Please install it using:\n"+
" $ gem install ritex\n\n"+e.inspect
rescue Racc::ParseError => e
maruku_error "Could not parse TeX: \n#{tex}"+
"\n\n #{e.inspect}"
end
nil
end
def to_html_inline_math_ritex
tex = self.math
mathml = convert_to_mathml_ritex(tex)
return mathml || []
end
def to_html_equation_ritex
tex = self.math
mathml = convert_to_mathml_ritex(tex)
return mathml || []
end
end end end