HTML5lib Sanitizer

Replaced native Sanitizer with HTML5lib version.
Synced with latest Maruku.
This commit is contained in:
Jacques Distler 2007-05-25 20:52:27 -05:00
parent 457ec8627c
commit 6b21ac484f
36 changed files with 6534 additions and 215 deletions

View file

@ -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

View file

@ -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}

View file

@ -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

View file

@ -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: `==`

View file

@ -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

View file

@ -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"

View file

@ -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)

View file

@ -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'],

View file

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