diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-05-30 16:35:36 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-05-30 16:35:36 +0000 |
commit | 88dea1a06d833067e5a6d9668c4b6829e027a9f5 (patch) | |
tree | c8a6486821da0c3cd34b2d756e33f59a50b1295c /lib/redcloth.rb | |
parent | 4311ecbc04e3256bd8d7c9a8668dff32349b0159 (diff) | |
download | redmine-88dea1a06d833067e5a6d9668c4b6829e027a9f5.tar.gz redmine-88dea1a06d833067e5a6d9668c4b6829e027a9f5.zip |
Adds multi-levels blockquotes support by using > at the beginning of lines.
Textile is preserved inside quoted text.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1479 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redcloth.rb')
-rw-r--r-- | lib/redcloth.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/redcloth.rb b/lib/redcloth.rb index fb6a053c6..344fd6c78 100644 --- a/lib/redcloth.rb +++ b/lib/redcloth.rb @@ -299,6 +299,8 @@ class RedCloth < String hard_break text unless @lite_mode refs text + # need to do this before text is split by #blocks + block_textile_quotes text blocks text end inline text @@ -576,6 +578,29 @@ class RedCloth < String lines.join( "\n" ) end end + + QUOTES_RE = /(^>+([^\n]*?)\n?)+/m + QUOTES_CONTENT_RE = /^([> ]+)(.*)$/m + + def block_textile_quotes( text ) + text.gsub!( QUOTES_RE ) do |match| + lines = match.split( /\n/ ) + quotes = '' + indent = 0 + lines.each do |line| + line =~ QUOTES_CONTENT_RE + bq,content = $1, $2 + l = bq.count('>') + if l != indent + quotes << ("\n\n" + (l>indent ? '<blockquote>' * (l-indent) : '</blockquote>' * (indent-l)) + "\n\n") + indent = l + end + quotes << (content + "\n") + end + quotes << ("\n" + '</blockquote>' * indent + "\n\n") + quotes + end + end CODE_RE = /(\W) @ |