Strip code indents (two spaces or one tab) if present.
This commit is contained in:
@@ -321,7 +321,10 @@ module Gollum
|
||||
@codemap.each do |id, spec|
|
||||
lang = spec[:lang]
|
||||
code = spec[:code]
|
||||
data.sub!(id, Gollum::Albino.new(code, lang).colorize)
|
||||
if code.all? { |line| line =~ /^( |\t)/ }
|
||||
code.gsub!(/^( |\t)/m, '')
|
||||
end
|
||||
data.gsub!(id, Gollum::Albino.new(code, lang).colorize)
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
@@ -270,6 +270,22 @@ context "Markup" do
|
||||
assert_equal output, rendered
|
||||
end
|
||||
|
||||
test "code blocks with two-space indent" do
|
||||
content = "a\n\n```ruby\n x = 1\n```\n\nb"
|
||||
output = "<p>a</p>\n\n<div class=\"highlight\"><pre>" +
|
||||
"<span class=\"n\">x</span> <span class=\"o\">=</span> " +
|
||||
"<span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>"
|
||||
compare(content, output)
|
||||
end
|
||||
|
||||
test "code blocks with one-tab indent" do
|
||||
content = "a\n\n```ruby\n\tx = 1\n```\n\nb"
|
||||
output = "<p>a</p>\n\n<div class=\"highlight\"><pre>" +
|
||||
"<span class=\"n\">x</span> <span class=\"o\">=</span> " +
|
||||
"<span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>"
|
||||
compare(content, output)
|
||||
end
|
||||
|
||||
test "escaped wiki link" do
|
||||
content = "a '[[Foo]], b"
|
||||
output = "<p>a [[Foo]], b</p>"
|
||||
|
||||
Reference in New Issue
Block a user