mirror of
https://github.com/jekyll/jekyll.git
synced 2026-04-28 03:01:03 -04:00
Refactor highlight tag to behave like the raw tag (#6821)
Merge pull request 6821
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user