let Gollum::Markup handle code blocks instead of RedCarpet
This commit is contained in:
@@ -449,6 +449,7 @@ module Gollum
|
|||||||
@wiki.sanitizer
|
@wiki.sanitizer
|
||||||
|
|
||||||
data = extract_tex(@data.dup)
|
data = extract_tex(@data.dup)
|
||||||
|
data = extract_code(data)
|
||||||
data = extract_tags(data)
|
data = extract_tags(data)
|
||||||
|
|
||||||
flags = [
|
flags = [
|
||||||
@@ -457,11 +458,11 @@ module Gollum
|
|||||||
:tables,
|
:tables,
|
||||||
:strikethrough,
|
:strikethrough,
|
||||||
:lax_htmlblock,
|
:lax_htmlblock,
|
||||||
:gh_blockcode,
|
|
||||||
:no_intraemphasis
|
:no_intraemphasis
|
||||||
]
|
]
|
||||||
data = Redcarpet.new(data, *flags).to_html
|
data = Redcarpet.new(data, *flags).to_html
|
||||||
data = process_tags(data)
|
data = process_tags(data)
|
||||||
|
data = process_code(data)
|
||||||
|
|
||||||
doc = Nokogiri::HTML::DocumentFragment.parse(data)
|
doc = Nokogiri::HTML::DocumentFragment.parse(data)
|
||||||
|
|
||||||
|
|||||||
+32
-2
@@ -422,6 +422,31 @@ context "Markup" do
|
|||||||
compare(content, output)
|
compare(content, output)
|
||||||
end
|
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
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
#
|
#
|
||||||
# Various
|
# Various
|
||||||
@@ -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 = @wiki.repo.index
|
||||||
index.add("Bilbo-Baggins.#{ext}", content)
|
index.add("Bilbo-Baggins.#{ext}", content)
|
||||||
index.commit("Add baggins")
|
index.commit("Add baggins")
|
||||||
|
|
||||||
page = @wiki.page("Bilbo 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?
|
if regexes.empty?
|
||||||
assert_equal normal(output), normal(rendered)
|
assert_equal normal(output), normal(rendered)
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user