HTML5lib Sanitizer
Replaced native Sanitizer with HTML5lib version. Synced with latest Maruku.
This commit is contained in:
parent
457ec8627c
commit
6b21ac484f
36 changed files with 6534 additions and 215 deletions
3
vendor/plugins/maruku/lib/maruku/defaults.rb
vendored
3
vendor/plugins/maruku/lib/maruku/defaults.rb
vendored
|
@ -31,6 +31,9 @@ Globals = {
|
|||
:maruku_signature => false,
|
||||
:code_background_color => '#fef',
|
||||
:code_show_spaces => false,
|
||||
|
||||
:filter_html => false,
|
||||
|
||||
:html_math_output_mathml => true, # also set :html_math_engine
|
||||
:html_math_engine => 'itex2mml', #ritex, itex2mml, none
|
||||
|
||||
|
|
|
@ -477,7 +477,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
|
|||
end
|
||||
|
||||
id = match[1]; url = match[2]; title = match[3];
|
||||
id = id.strip.downcase.gsub(' ','_')
|
||||
id = sanitize_ref_id(id)
|
||||
|
||||
hash = self.refs[id] = {:url=>url,:title=>title}
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
|
|||
end
|
||||
|
||||
def extension_meta(src, con, break_on_chars)
|
||||
if m = src.read_regexp(/([^\s\:]+):/)
|
||||
if m = src.read_regexp(/([^\s\:\"\']+):/)
|
||||
name = m[1]
|
||||
al = read_attribute_list(src, con, break_on_chars)
|
||||
# puts "#{name}=#{al.inspect}"
|
||||
|
@ -581,9 +581,9 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
|
|||
ref_id = read_ref_id(src,con)
|
||||
if ref_id
|
||||
if ref_id.size == 0
|
||||
ref_id = children.to_s.downcase.gsub(' ','_')
|
||||
ref_id = sanitize_ref_id(children.to_s)
|
||||
else
|
||||
ref_id = ref_id.downcase
|
||||
ref_id = sanitize_ref_id(ref_id)
|
||||
end
|
||||
con.push_element md_link(children, ref_id)
|
||||
else
|
||||
|
|
|
@ -108,6 +108,7 @@ module MaRuKu
|
|||
# Input is a LineSource
|
||||
def t2_parse_blocks(src, output)
|
||||
while src.cur_line
|
||||
l = src.shift_line
|
||||
|
||||
# ignore empty line
|
||||
if l.t2_empty? then
|
||||
|
@ -115,7 +116,6 @@ module MaRuKu
|
|||
next
|
||||
end
|
||||
|
||||
l = src.shift_line
|
||||
# TODO: lists
|
||||
# TODO: xml
|
||||
# TODO: `==`
|
||||
|
|
|
@ -741,7 +741,17 @@ of the form `#ff00ff`.
|
|||
return a
|
||||
end
|
||||
|
||||
=begin maruku_doc
|
||||
Attribute: filter_html
|
||||
Scope: document
|
||||
|
||||
If true, raw HTML is discarded from the output.
|
||||
|
||||
=end
|
||||
|
||||
def to_html_raw_html
|
||||
return [] if get_setting(:filter_html)
|
||||
|
||||
raw_html = self.raw_html
|
||||
if rexml_doc = @parsed_html
|
||||
root = rexml_doc.root
|
||||
|
|
|
@ -152,7 +152,7 @@ end end
|
|||
module MaRuKu; module Out; module Latex
|
||||
|
||||
def to_latex_hrule; "\n\\vspace{.5em} \\hrule \\vspace{.5em}\n" end
|
||||
def to_latex_linebreak; "\\linebreak " end
|
||||
def to_latex_linebreak; "\\newline " end
|
||||
|
||||
def to_latex_paragraph
|
||||
children_to_latex+"\n\n"
|
||||
|
|
|
@ -146,6 +146,10 @@ module MaRuKu; module Strings
|
|||
s[0, i+1].strip
|
||||
end
|
||||
|
||||
def sanitize_ref_id(x)
|
||||
x.downcase.gsub(' ','_').gsub(/[^\w]/,'')
|
||||
end
|
||||
|
||||
|
||||
# removes initial quote
|
||||
def unquote(s)
|
||||
|
|
|
@ -155,7 +155,7 @@ module MaRuKu; module Tests
|
|||
["[a]", [ md_link(["a"],'a')], 'Empty link'],
|
||||
["[a][]", ],
|
||||
["[a][]b", [ md_link(["a"],'a'),'b'], 'Empty link'],
|
||||
["[a\\]][]", [ md_link(["a]"],'a]')], 'Escape inside link'],
|
||||
["[a\\]][]", [ md_link(["a]"],'a')], 'Escape inside link (throw ?] away)'],
|
||||
|
||||
["[a", :throw, 'Link not closed'],
|
||||
["[a][", :throw, 'Ref not closed'],
|
||||
|
|
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.5'
|
||||
Version = '0.5.6'
|
||||
|
||||
MarukuURL = 'http://maruku.rubyforge.org/'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue