Remove the GFM parser; it makes no sense
The new versions of GitHub::Markup will automatically render GFM for Markdown documents if the necessary gems are installed.
This commit is contained in:
@@ -484,64 +484,4 @@ module Gollum
|
||||
def update_cache(type, id, data)
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
require 'redcarpet'
|
||||
|
||||
class MarkupGFM < Markup
|
||||
def render(no_follow = false, encoding = nil)
|
||||
sanitize = no_follow ?
|
||||
@wiki.history_sanitizer :
|
||||
@wiki.sanitizer
|
||||
|
||||
data = extract_tex(@data.dup)
|
||||
data = extract_code(data)
|
||||
data = extract_tags(data)
|
||||
|
||||
if Gem::Version.new(Redcarpet::VERSION) > Gem::Version.new("1.17.2")
|
||||
html_renderer = Redcarpet::Render::HTML.new({
|
||||
:autolink => true,
|
||||
:fenced_code_blocks => true,
|
||||
:tables => true,
|
||||
:strikethrough => true,
|
||||
:lax_htmlblock => true,
|
||||
:no_intraemphasis => true
|
||||
})
|
||||
markdown = Redcarpet::Markdown.new(html_renderer)
|
||||
data = markdown.render(data)
|
||||
else
|
||||
flags = [
|
||||
:autolink,
|
||||
:fenced_code,
|
||||
:tables,
|
||||
:strikethrough,
|
||||
:lax_htmlblock,
|
||||
:no_intraemphasis
|
||||
]
|
||||
data = Redcarpet.new(data, *flags).to_html
|
||||
end
|
||||
data = process_tags(data)
|
||||
data = process_code(data, encoding)
|
||||
|
||||
doc = Nokogiri::HTML::DocumentFragment.parse(data)
|
||||
|
||||
doc.search('pre').each do |node|
|
||||
next unless lang = node['lang']
|
||||
next unless lexer = Pygments::Lexer[lang]
|
||||
text = node.inner_text
|
||||
html = lexer.highlight(text)
|
||||
node.replace(html)
|
||||
end
|
||||
|
||||
doc = sanitize.clean_node!(doc) if sanitize
|
||||
yield doc if block_given?
|
||||
|
||||
data = doc.to_html
|
||||
data = process_tex(data)
|
||||
data
|
||||
end
|
||||
end
|
||||
rescue LoadError
|
||||
MarkupGFM = Markup
|
||||
end
|
||||
end
|
||||
|
||||
@@ -456,11 +456,6 @@ np.array([[2,2],[1,3]],np.float)
|
||||
# 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)
|
||||
|
||||
Reference in New Issue
Block a user