Refactor highlight tag to behave like the raw tag (#6821)

Merge pull request 6821
This commit is contained in:
Ashwin Maroli
2019-03-15 22:18:21 +05:30
committed by jekyllbot
parent d807deb647
commit 36404b9a43
4 changed files with 81 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
module Jekyll
module Tags
class HighlightBlock < Liquid::Block
class HighlightBlock < Liquid::Raw
include Liquid::StandardFilters
# The regular expression syntax checker. Start with the language specifier.
@@ -28,10 +28,12 @@ module Jekyll
end
end
LEADING_OR_TRAILING_LINE_TERMINATORS = %r!\A(\n|\r)+|(\n|\r)+\z!.freeze
def render(context)
prefix = context["highlighter_prefix"] || ""
suffix = context["highlighter_suffix"] || ""
code = super.to_s.gsub(%r!\A(\n|\r)+|(\n|\r)+\z!, "")
code = @body.gsub(LEADING_OR_TRAILING_LINE_TERMINATORS, "")
output =
case context.registers[:site].highlighter
@@ -101,6 +103,8 @@ module Jekyll
"<figure class=\"highlight\"><pre><code #{code_attributes}>"\
"#{code.chomp}</code></pre></figure>"
end
def ensure_valid_markup(tag_name, markup, parse_context); end
end
end
end