Textile formatting:

* escape html tags, except pre tags (#807, #795)
* try to avoid unwanted quick phrase modifiers

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1216 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-03-09 11:47:36 +00:00
parent 522b9e6b5b
commit a92cce3851
1 changed files with 11 additions and 4 deletions

View File

@ -295,6 +295,7 @@ class RedCloth < String
@pre_list = [] @pre_list = []
rip_offtags text rip_offtags text
no_textile text no_textile text
escape_html_tags text
hard_break text hard_break text
unless @lite_mode unless @lite_mode
refs text refs text
@ -375,18 +376,18 @@ class RedCloth < String
re = re =
case rtype case rtype
when :limit when :limit
/(\W) /(^|[>\s])
(#{rcq}) (#{rcq})
(#{C}) (#{C})
(?::(\S+?))? (?::(\S+?))?
(\S.*?\S|\S) ([^\s\-].*?[^\s\-]|\w)
#{rcq} #{rcq}
(?=\W)/x (?=[[:punct:]]|\s|$)/x
else else
/(#{rcq}) /(#{rcq})
(#{C}) (#{C})
(?::(\S+))? (?::(\S+))?
(\S.*?\S|\S) ([^\s\-].*?[^\s\-]|\w)
#{rcq}/xm #{rcq}/xm
end end
[rc, ht, re, rtype] [rc, ht, re, rtype]
@ -1128,5 +1129,11 @@ class RedCloth < String
end end
end end
end end
ALLOWED_TAGS = %w(redpre pre)
def escape_html_tags(text)
text.gsub!(%r{<((\/?)(\w+))}) {|m| ALLOWED_TAGS.include?($3) ? "<#{$1}" : "&lt;#{$1}" }
end
end end