New solution for passing restrictions to RedCloth - all tests pass with ruby 1.8 (just invoking rake)
This commit is contained in:
parent
ab3927499f
commit
d80c773b01
|
@ -28,14 +28,22 @@ module Jekyll
|
||||||
def convert(content)
|
def convert(content)
|
||||||
setup
|
setup
|
||||||
|
|
||||||
restrictions = Array.new
|
# Shortcut if config doesn't contain RedCloth section
|
||||||
if !@config['redcloth'].nil?
|
return RedCloth.new(content).to_html if @config['redcloth'].nil?
|
||||||
@config['redcloth'].each do |key, value|
|
|
||||||
restrictions << key.to_sym if value
|
# List of attributes defined on RedCloth
|
||||||
end
|
# (from http://redcloth.rubyforge.org/classes/RedCloth/TextileDoc.html)
|
||||||
|
attrs = ['filter_classes', 'filter_html', 'filter_ids', 'filter_styles',
|
||||||
|
'hard_breaks', 'lite_mode', 'no_span_caps', 'sanitize_html']
|
||||||
|
|
||||||
|
r = RedCloth.new(content)
|
||||||
|
|
||||||
|
# Set attributes in r if they are NOT nil in the config
|
||||||
|
attrs.each do |attr|
|
||||||
|
r.instance_variable_set("@#{attr}".to_sym, @config['redcloth'][attr]) unless @config['redcloth'][attr].nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
RedCloth.new(content, restrictions).to_html
|
r.to_html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -54,4 +54,33 @@ class TestRedCloth < Test::Unit::TestCase
|
||||||
assert_equal "<p>line1\nline2</p>", @textile.convert("p. line1\nline2").strip
|
assert_equal "<p>line1\nline2</p>", @textile.convert("p. line1\nline2").strip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "RedCloth w/no_span_caps set to false" do
|
||||||
|
setup do
|
||||||
|
config = {
|
||||||
|
'redcloth' => {
|
||||||
|
'no_span_caps' => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@textile = TextileConverter.new config
|
||||||
|
end
|
||||||
|
should "generate span tags around capitalized words" do
|
||||||
|
assert_equal "<p><span class=\"caps\">NSC</span></p>", @textile.convert("NSC").strip
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "RedCloth w/no_span_caps set to true" do
|
||||||
|
setup do
|
||||||
|
config = {
|
||||||
|
'redcloth' => {
|
||||||
|
'no_span_caps' => true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@textile = TextileConverter.new config
|
||||||
|
end
|
||||||
|
|
||||||
|
should "not generate span tags around capitalized words" do
|
||||||
|
assert_equal "<p>NSC</p>", @textile.convert("NSC").strip
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue