Sync with latest Maruku
Apparently, Maruku had trouble with the latest release of Ruby (1.8.6, patchlevel 110). This should fix it.
This commit is contained in:
parent
5dd75d4cb0
commit
148afb77e0
|
@ -1,12 +1,11 @@
|
|||
class String
|
||||
|
||||
# fix some LaTeX command-name clashes
|
||||
def fix_latex
|
||||
if #{html_math_engine} == 'itex2mml'
|
||||
s = self.gsub("\\mathop{", "\\operatorname{")
|
||||
s.gsub("\\space{", "\\itexspace{")
|
||||
else
|
||||
self
|
||||
end
|
||||
end
|
||||
# fix some LaTeX command-name clashes
|
||||
def fix_latex
|
||||
if #{html_math_engine} == 'itex2mml'
|
||||
s = self.gsub("\\mathop{", "\\operatorname{")
|
||||
s.gsub("\\space{", "\\itexspace{")
|
||||
else
|
||||
self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,8 +14,8 @@ module MaRuKu; module Out; module HTML
|
|||
doc = Document.new(mathml, {:respect_whitespace =>:all}).root
|
||||
return doc
|
||||
rescue LoadError => e
|
||||
maruku_error "Could not load package 'itex2mml'.\n"+
|
||||
"Please install it."
|
||||
maruku_error "Could not load package 'itex2mml'.\n"+ "Please install it." unless $already_warned_itex2mml
|
||||
$already_warned_itex2mml = true
|
||||
rescue REXML::ParseException => e
|
||||
maruku_error "Invalid MathML TeX: \n#{add_tabs(tex,1,'tex>')}"+
|
||||
"\n\n #{e.inspect}"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
module MaRuKu; module Out; module Latex
|
||||
|
||||
require 'maruku/ext/math/latex_fix'
|
||||
|
||||
module MaRuKu; module Out; module Latex
|
||||
|
||||
def to_latex_inline_math
|
||||
s = "$#{self.math.strip}$".fix_latex
|
||||
"$#{self.math.strip}$".fix_latex
|
||||
end
|
||||
|
||||
def to_latex_equation
|
||||
|
|
|
@ -173,6 +173,7 @@ Disabled by default because of security concerns.
|
|||
self.abbreviations.each do |abbrev, title|
|
||||
reg = Regexp.new(Regexp.escape(abbrev))
|
||||
self.replace_each_string do |s|
|
||||
# bug if many abbreviations are present (agorf)
|
||||
if m = reg.match(s)
|
||||
e = md_abbr(abbrev.dup, title ? title.dup : nil)
|
||||
[m.pre_match, e, m.post_match]
|
||||
|
|
|
@ -18,9 +18,16 @@
|
|||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#++
|
||||
|
||||
|
||||
require 'rexml/document'
|
||||
|
||||
begin
|
||||
require 'rexml/formatters/pretty'
|
||||
require 'rexml/formatters/default'
|
||||
$rexml_new_version = true
|
||||
rescue LoadError
|
||||
$rexml_new_version = false
|
||||
end
|
||||
|
||||
class String
|
||||
# A string is rendered into HTML by creating
|
||||
# a REXML::Text node. REXML takes care of all the encoding.
|
||||
|
@ -30,11 +37,6 @@ class String
|
|||
end
|
||||
|
||||
|
||||
class REXML::Element
|
||||
# We only want to output the children in Maruku::to_html
|
||||
public :write_children
|
||||
end
|
||||
|
||||
# This module groups all functions related to HTML export.
|
||||
module MaRuKu; module Out; module HTML
|
||||
include REXML
|
||||
|
@ -42,7 +44,7 @@ module MaRuKu; module Out; module HTML
|
|||
# Render as an HTML fragment (no head, just the content of BODY). (returns a string)
|
||||
def to_html(context={})
|
||||
indent = context[:indent] || -1
|
||||
ie_hack = context[:ie_hack] ||true
|
||||
ie_hack = context[:ie_hack] || true
|
||||
|
||||
div = Element.new 'dummy'
|
||||
children_to_html.each do |e|
|
||||
|
@ -60,7 +62,21 @@ module MaRuKu; module Out; module HTML
|
|||
# REXML Bug? if indent!=-1 whitespace is not respected for 'pre' elements
|
||||
# containing code.
|
||||
xml =""
|
||||
div.write_children(xml,indent,transitive=true,ie_hack)
|
||||
|
||||
if $rexml_new_version
|
||||
formatter = if indent > -1
|
||||
REXML::Formatters::Pretty.new( indent, ie_hack )
|
||||
else
|
||||
REXML::Formatters::Default.new( ie_hack )
|
||||
end
|
||||
formatter.write( div, xml)
|
||||
else
|
||||
div.write(xml,indent,transitive=true,ie_hack)
|
||||
end
|
||||
|
||||
xml.gsub!(/\A<dummy>\s*/,'')
|
||||
xml.gsub!(/\s*<\/dummy>\Z/,'')
|
||||
xml.gsub!(/\A<dummy\s*\/>/,'')
|
||||
xml
|
||||
end
|
||||
|
||||
|
@ -141,6 +157,23 @@ Synonim for `title`.
|
|||
=end
|
||||
|
||||
|
||||
# Render to an HTML fragment (returns a REXML document tree)
|
||||
def to_html_tree
|
||||
div = Element.new 'div'
|
||||
div.attributes['class'] = 'maruku_wrapper_div'
|
||||
children_to_html.each do |e|
|
||||
div << e
|
||||
end
|
||||
|
||||
# render footnotes
|
||||
if @doc.footnotes_order.size > 0
|
||||
div << render_footnotes
|
||||
end
|
||||
|
||||
doc = Document.new(nil,{:respect_whitespace =>:all})
|
||||
doc << div
|
||||
end
|
||||
|
||||
=begin maruku_doc
|
||||
Attribute: css
|
||||
Scope: document
|
||||
|
@ -154,22 +187,7 @@ Example:
|
|||
CSS: style.css math.css
|
||||
|
||||
=end
|
||||
# Render to an HTML fragment (returns a REXML document tree)
|
||||
def to_html_tree
|
||||
div = Element.new 'div'
|
||||
div.attributes['class'] = 'maruku_wrapper_div'
|
||||
children_to_html.each do |e|
|
||||
div << e
|
||||
end
|
||||
|
||||
# render footnotes
|
||||
if @doc.footnotes_order.size > 0
|
||||
div << render_footnotes
|
||||
end
|
||||
|
||||
doc = Document.new(nil,{:respect_whitespace =>:all})
|
||||
doc << div
|
||||
end
|
||||
|
||||
# Render to a complete HTML document (returns a REXML document tree)
|
||||
def to_html_document_tree
|
||||
|
@ -465,7 +483,7 @@ by Maruku, to have the same results in both HTML and LaTeX.
|
|||
end
|
||||
|
||||
def source2html(source)
|
||||
source = source.gsub(/&/,'&')
|
||||
# source = source.gsub(/&/,'&')
|
||||
source = Text.normalize(source)
|
||||
source = source.gsub(/\'/,''') # IE bug
|
||||
source = source.gsub(/'/,''') # IE bug
|
||||
|
@ -591,7 +609,7 @@ of the form `#ff00ff`.
|
|||
code = Element.new 'code', pre
|
||||
s = source
|
||||
|
||||
s = s.gsub(/&/,'&')
|
||||
# s = s.gsub(/&/,'&')
|
||||
s = Text.normalize(s)
|
||||
s = s.gsub(/\'/,''') # IE bug
|
||||
s = s.gsub(/'/,''') # IE bug
|
||||
|
@ -892,7 +910,7 @@ If true, raw HTML is discarded from the output.
|
|||
# Entity.new(entity_name)
|
||||
Text.new('&#%d;' % [entity_name], false, nil, true)
|
||||
else
|
||||
Text.new('&%s;' % [entity_name])
|
||||
Text.new('&%s;' % [entity_name], false, nil, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
2
vendor/plugins/maruku/lib/maruku/version.rb
vendored
2
vendor/plugins/maruku/lib/maruku/version.rb
vendored
|
@ -19,7 +19,7 @@
|
|||
#++
|
||||
|
||||
module MaRuKu
|
||||
Version = '0.5.6'
|
||||
Version = '0.5.7'
|
||||
|
||||
MarukuURL = 'http://maruku.rubyforge.org/'
|
||||
|
||||
|
|
Loading…
Reference in a new issue