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
This commit is contained in:
@@ -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)
|
||||
@
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user