Skip to content

Commit

Permalink
only modify rouge output if using CommonMark
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed Feb 12, 2018
1 parent f98e8ef commit aa13a4c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/jekyll-commonmark-ghpages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,25 @@ def convert(content)

class Jekyll::Tags::HighlightBlock
alias render_rouge_without_ghpages_hack render_rouge
alias render_without_ghpages_hack render

def render(context)
@render_ghpages_hack_context = context
render_without_ghpages_hack(context)
end

def render_rouge(context)
render_rouge_without_ghpages_hack(context)
.gsub(/\r?\n/, "<br data-jekyll-commonmark-ghpages>")
rendered = render_rouge_without_ghpages_hack(context)

processor = @render_ghpages_hack_context
.registers[:site]
.find_converter_instance(Jekyll::Converters::Markdown)
.get_processor

if processor.is_a?(Jekyll::Converters::Markdown::CommonMarkGhPages)
rendered.gsub!(/\r?\n/, "<br data-jekyll-commonmark-ghpages>")
end

rendered
end
end

0 comments on commit aa13a4c

Please sign in to comment.