lib/trac-wiki/tree.rb in trac-wiki-0.2.24 vs lib/trac-wiki/tree.rb in trac-wiki-0.3.10

- old
+ new

@@ -1,7 +1,6 @@ require 'pp' -require 'sanitize' module TracWiki class RawHtml def initialize(text) @text = text @@ -109,14 +108,10 @@ nil end def to_html ret = tree_to_html(@root) - #print "bf san:", ret, "\n" - #ret = Sanitize.clean(ret, san_conf) - #print "af san:", ret, "\n" - #ret + "\n" ret end def tree_to_html(node) tag = node.tag if tag.nil? @@ -142,11 +137,11 @@ return "<#{tag}#{attrs_to_s(tag, node.attrs)}>#{cont_to_s(node.cont)}</#{tag}>#{nl}" end - TAGS_APPEND_NL = [:div, :p, :li, :ol, :ul, :dl, :table, :tr, :td ] + TAGS_APPEND_NL = [:div, :p, :li, :ol, :ul, :dl, :table, :tr, :td , :th] TAGS_FORCE_PAIR = [:a, :td, :h1, :h2, :h3, :h4, :h5, :h6, :div, :script] TAGS_ALLOVED = [:a, :h1, :h2, :h3, :h4, :h5, :h6, :div, :span, :p, :pre, :li, :ul, :ol, :dl, :dt, :dd, @@ -162,11 +157,11 @@ :option => [:disabled, :selected, :label, :value, :name], :a => [:name, :href], :img => [:src, :width, :height, :align, :valign, :style, :alt, :title], :td => [:colspan, :rowspan, :style], :th => [:colspan, :rowspan, :style], - :_all => [:class, :id], + :_all => [:class, :title, :id], } ATTRIBUTE_STYLE_REX = /\A( text-align:(center|right|left) | margin: \d+(px|em)? | ; @@ -197,27 +192,27 @@ TracWiki::Parser.escapeHTML(c.to_s) end end.join('') end - def san_conf - return @san_conf if @san_conf - conf = { elements: ['tt', 'form', 'input', 'span', 'div'], - output: :xhtml, - attributes: { 'form' => ['action', 'meth'], - 'input' => ['type', 'value'], - 'span' => ['class', 'id'], - 'div' => ['class', 'id'], - 'a' => ['class', 'id', 'name', 'href'], - :all => ['class', 'id'], - }, - } - - @san_conf = Sanitize::Config::RELAXED.merge(conf){|k,o,n| o.is_a?(Hash) ? o.merge(n) : - o.is_a?(Array) ? o + n : - n } - - #pp @san_conf - @san_conf - end +# def san_conf +# return @san_conf if @san_conf +# conf = { elements: ['tt', 'form', 'input', 'span', 'div'], +# output: :xhtml, +# attributes: { 'form' => ['action', 'meth'], +# 'input' => ['type', 'value'], +# 'span' => ['class', 'id'], +# 'div' => ['class', 'id'], +# 'a' => ['class', 'id', 'name', 'href'], +# :all => ['class', 'id'], +# }, +# } +# +# @san_conf = Sanitize::Config::RELAXED.merge(conf){|k,o,n| o.is_a?(Hash) ? o.merge(n) : +# o.is_a?(Array) ? o + n : +# n } +# +# #pp @san_conf +# @san_conf +# end end end