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 | |
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')
-rw-r--r-- | lib/redcloth.rb | 25 | ||||
-rw-r--r-- | lib/redmine/wiki_formatting.rb | 2 |
2 files changed, 26 insertions, 1 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) @ diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 3c1eac020..7197af2c3 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -45,7 +45,7 @@ module Redmine # Patch for RedCloth. Fixed in RedCloth r128 but _why hasn't released it yet. # <a href="http://code.whytheluckystiff.net/redcloth/changeset/128">http://code.whytheluckystiff.net/redcloth/changeset/128</a> def hard_break( text ) - text.gsub!( /(.)\n(?!\n|\Z| *([#*=]+(\s|$)|[{|]))/, "\\1<br />\n" ) if hard_breaks + text.gsub!( /(.)\n(?!\n|\Z|>| *(>? *[#*=]+(\s|$)|[{|]))/, "\\1<br />\n" ) if hard_breaks end # Patch to add code highlighting support to RedCloth |