let Gollum::Markup handle code blocks instead of RedCarpet

This commit is contained in:
rick
2011-09-29 11:02:35 -06:00
parent 6887c89d5c
commit 8c1f82d894
2 changed files with 34 additions and 3 deletions
+2 -1
View File
@@ -449,6 +449,7 @@ module Gollum
@wiki.sanitizer
data = extract_tex(@data.dup)
data = extract_code(data)
data = extract_tags(data)
flags = [
@@ -457,11 +458,11 @@ module Gollum
:tables,
:strikethrough,
:lax_htmlblock,
:gh_blockcode,
:no_intraemphasis
]
data = Redcarpet.new(data, *flags).to_html
data = process_tags(data)
data = process_code(data)
doc = Nokogiri::HTML::DocumentFragment.parse(data)
+32 -2
View File
@@ -421,6 +421,31 @@ context "Markup" do
"</span> <span class=\"mi\">2</span>\n</pre>\n</div>\n\n\n<p>b</p>"
compare(content, output)
end
test "code with wiki links" do
content = <<-END
booya
``` python
np.array([[2,2],[1,3]],np.float)
```
END
# rendered with Gollum::Markup
page, rendered = render_page(content)
assert_markup_highlights_code Gollum::Markup, rendered
if Gollum.const_defined?(:MarkupGFM)
rendered_gfm = Gollum::MarkupGFM.new(page).render
assert_markup_highlights_code Gollum::MarkupGFM, rendered_gfm
end
end
def assert_markup_highlights_code(markup_class, rendered)
assert_match /div class="highlight"/, rendered, "#{markup_class} doesn't highlight code\n #{rendered}"
assert_match /span class="n"/, rendered, "#{markup_class} doesn't highlight code\n #{rendered}"
assert_match /\(\[\[/, rendered, "#{markup_class} parses out wiki links\n#{rendered}"
end
#########################################################################
#
@@ -515,13 +540,18 @@ context "Markup" do
#
#########################################################################
def compare(content, output, ext = "md", regexes = [])
def render_page(content, ext = "md")
index = @wiki.repo.index
index.add("Bilbo-Baggins.#{ext}", content)
index.commit("Add baggins")
page = @wiki.page("Bilbo Baggins")
rendered = Gollum::Markup.new(page).render
[page, Gollum::Markup.new(page).render]
end
def compare(content, output, ext = "md", regexes = [])
page, rendered = render_page(content, ext)
if regexes.empty?
assert_equal normal(output), normal(rendered)
else