Update RedCloth to 4.x

Use Bundler to manage RedCloth
gem. 4.x should be much faster
and less buggy. Unfortunately,
it doesn't support mixed
Textile/Markdown syntax. So
we keep an (appropriately
renamed) copy of 3.x around,
for the users of the "Mixed"
text filter.
master
Jacques Distler 2010-11-03 23:32:55 -05:00
parent cca857ed3a
commit 4be1a58a24
5 changed files with 19 additions and 9 deletions

View File

@ -3,6 +3,7 @@ gem "sqlite3-ruby", :require => "sqlite3"
gem "itextomml", ">=1.4.5"
gem "mongrel", ">=1.2.0.pre2"
gem "rubyzip"
gem "RedCloth", ">=4.0.0"
gem "erubis"
gem "nokogiri"
gem "rake"

View File

@ -478,7 +478,7 @@ EOL
"<meta http-equiv=\"Refresh\" content=\"0;URL=HomePage.#{html_ext}\" /></head></html>"
end
dir = Rails.root.join('public')
Dir["#{dir}/**/*"].each do |f|
Dir["#{dir}/{images,javascripts,s5,stylesheets}/**/*"].each do |f|
zip_out.add "public#{f.sub(dir.to_s,'')}", f
end
end

View File

@ -6,6 +6,7 @@ require 'maruku'
require 'maruku/ext/math'
require_dependency 'rdocsupport'
require 'redcloth'
require 'oldredcloth'
# The markup engines are Chunks that call the one of RedCloth
# or RDoc to convert text. This markup occurs when the chunk is required
@ -113,7 +114,7 @@ module Engines
class Mixed < AbstractEngine
def mask
@content.as_utf8
redcloth = RedCloth.new(@content, @content.options[:engine_opts])
redcloth = OldRedCloth.new(@content, @content.options[:engine_opts])
redcloth.filter_html = false
redcloth.no_span_caps = false
html = redcloth.to_html

View File

@ -164,7 +164,7 @@
#
# class RedCloth::Textile.new( str )
class RedCloth < String
class OldRedCloth < String
VERSION = '3.0.3'
DEFAULT_RULES = [:textile, :markdown]

View File

@ -358,11 +358,12 @@ END_THM
assert_match_markup_parsed_as(re, textile_and_markdown)
set_web_property :markup, :textile
assert_markup_parsed_as(
"<p>Markdown heading<br/>================</p>\n\n\n\t<h2>Textile heading</h2>" +
"\n\n\n\t<p><strong>some</strong> <b>text</b> <em>with</em> <del>styles</del></p>" +
"\n\n\n\t<ul>\n\t<li>list 1</li>\n\t\t<li>list 2</li>\n\t</ul>",
"<p>Markdown heading<br/>\n====</p>\n<h2>Textile heading</h2>" +
"\n<p><strong>some</strong> <b>text</b> <em>with</em> <del>styles</del></p>" +
"\n<ul>\n\t<li>list 1</li>\n\t<li>list 2</li>\n</ul>",
textile_and_markdown)
# Mixed Textile+Markdown markup not supported by RedCloth 4.x
set_web_property :markup, :mixed
assert_markup_parsed_as(
"<h1>Markdown heading</h1>\n\n\n\t<h2>Textile heading</h2>\n\n\n\t" +
@ -370,7 +371,14 @@ END_THM
"<ul>\n\t<li>list 1</li>\n\t\t<li>list 2</li>\n\t</ul>",
textile_and_markdown)
end
def test_textile_pre
set_web_property :markup, :textile
assert_markup_parsed_as("<pre>\n<code>\n a == 16\n</code>\n</pre>\n<p>foo bar" +
"<br/>\n<pre><br/>\n<code>\n b == 16\n</code><br/>\n</pre></p>",
"<pre>\n<code>\n a == 16\n</code>\n</pre>\nfoo bar\n<pre>\n<code>\n b == 16\n</code>\n</pre>")
end
def test_rdoc
set_web_property :markup, :rdoc
@ -461,7 +469,7 @@ END_THM
set_web_property :markup, :textile
assert_markup_parsed_as(
"<p>$$<span class='newWikiWord'>foo<a href='../show/foo'>?" +
"</a></span>$$<br/>$<span class='newWikiWord'>foo<a " +
"</a></span>$$<br/>\n$<span class='newWikiWord'>foo<a " +
"href='../show/foo'>?</a></span>$</p>",
"$$[[foo]]$$\n$[[foo]]$")
end