Fix Maruku Escaping Bug

Sync with latest Maruku (now on github).
lib/maruku/ext/math/mathml_engines/none.rb should
HTML-escape the TeX source code. No it does.
This commit is contained in:
Jacques Distler 2009-05-13 01:27:39 -05:00
parent ec7141942b
commit a84648cff1
20 changed files with 1725 additions and 136 deletions

View file

@ -6,7 +6,7 @@ module MaRuKu; module Out; module HTML
# or return an empty array on error
# return []
# or have a string parsed by REXML:
tex = tex.gsub('&','&')
tex = tex.escapeHTML
mathml = "<code>#{tex}</code>"
return Document.new(mathml).root
end

View file

@ -91,10 +91,10 @@ module Helpers
raw_html = "<marukuwrap>#{raw_html}</marukuwrap>"
e.instance_variable_set :@parsed_html,
REXML::Document.new(raw_html)
rescue #Exception => ex
rescue REXML::ParseException => ex
e.instance_variable_set :@parsed_html, nil
# tell_user "Malformed block of HTML:\n"+
# add_tabs(raw_html,1,'|')
maruku_recover "REXML cannot parse this block of HTML/XML:\n"+
add_tabs(raw_html,1,'|') + "\n"+ex.inspect
# " #{raw_html.inspect}\n\n"+ex.inspect
end
e

View file

@ -198,14 +198,17 @@ Disabled by default because of security concerns.
XPath.match(doc, "//*[attribute::markdown]" ).each do |e|
# puts "Found #{e}"
# should we parse block-level or span-level?
parse_blocks = (e.attributes['markdown'] == 'block') ||
block_tags.include?(e.name)
# remove 'markdown' attribute
e.delete_attribute 'markdown'
how = e.attributes['markdown']
parse_blocks = (how == 'block') || block_tags.include?(e.name)
# Select all text elements of e
XPath.match(e, "//text()" ).each { |original_text|
s = original_text.value.strip
if s.size > 0
# puts "Parsing #{s.inspect} as blocks: #{parse_blocks} (#{e.name}, #{e.attributes['markdown']}) "
el = md_el(:dummy,
parse_blocks ? parse_text_as_markdown(s) :
parse_lines_as_span([s]) )
@ -217,7 +220,11 @@ Disabled by default because of security concerns.
end
}
# remove 'markdown' attribute
e.delete_attribute 'markdown'
end
end

View file

@ -19,7 +19,7 @@
#++
module MaRuKu
Version = '0.5.9'
Version = '0.6.0'
MarukuURL = 'http://maruku.rubyforge.org/'