Revert "Refactor `highlight` tag to behave like the `raw` tag" (#7592)
* Revert "Refactor `highlight` tag to behave like the `raw` tag (#6821)"
This reverts commit 36404b9a43
.
* use Liquid `raw` in upgrading document
* let the minor improvements stay
* Revert entry in History.markdown
This commit is contained in:
parent
36d3aed1f2
commit
f4ee82650e
|
@ -10,7 +10,6 @@
|
|||
* Drop support for rdiscount (#6988)
|
||||
* Drop support for `jekyll-watch-1.4.0` and older (#7287)
|
||||
* Incorporate `relative_url` filter in `link` tag (#6727)
|
||||
* Refactor `highlight` tag to behave like the `raw` tag (#6821)
|
||||
* Upgrade kramdown dependency to v2.x (#7492)
|
||||
* Upgrade i18n to v1.x (#6931)
|
||||
* Add `Jekyll::Cache` class to handle caching on disk (#7169)
|
||||
|
|
|
@ -35,8 +35,10 @@ gem update jekyll
|
|||
</p>
|
||||
|
||||
{% highlight diff %}
|
||||
{% raw %}
|
||||
- {{ site.baseurl }}/{% post_url 2018-03-20-hello-world.markdown %}
|
||||
+ {% post_url 2018-03-20-hello-world.markdown %}
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -31,47 +31,3 @@ Feature: Syntax Highlighting
|
|||
When I run jekyll build
|
||||
Then I should get a zero exit-status
|
||||
And I should see "<span class="nc">RewriteCond</span>" in "_site/index.html"
|
||||
|
||||
Scenario: highlighting an Liquid example
|
||||
Given I have an "inspect.md" file with content:
|
||||
"""
|
||||
---
|
||||
title: Inspect Filter
|
||||
---
|
||||
You can inspect a page's attributes with the `inspect` filter. You may enclose the
|
||||
entire introspection within `<pre></pre>` tags to preserve the formatting:
|
||||
{% highlight html %}
|
||||
<pre id="inspect-filter">
|
||||
{{ page | inspect }}
|
||||
</pre>
|
||||
{% endhighlight %}
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit-status
|
||||
And I should see "<code class=\"language-html\" data-lang=\"html\">" in "_site/inspect.html"
|
||||
And I should see "{{ page | inspect }}" in "_site/inspect.html"
|
||||
|
||||
Scenario: highlighting an included snippet
|
||||
Given I have an _includes directory
|
||||
And I have an "_includes/inspector.html" file with content:
|
||||
"""
|
||||
<pre id="inspect-filter">
|
||||
{{ page | inspect }}
|
||||
</pre>
|
||||
"""
|
||||
And I have an "inspect.md" file with content:
|
||||
"""
|
||||
---
|
||||
title: Inspect Filter
|
||||
---
|
||||
You can inspect a page's attributes with the `inspect` filter. You may enclose the
|
||||
entire introspection within `<pre></pre>` tags to preserve the formatting:
|
||||
{% highlight html %}
|
||||
{% include inspector.html %}
|
||||
{% endhighlight %}
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then I should get a zero exit-status
|
||||
And I should see "<code class=\"language-html\" data-lang=\"html\">" in "_site/inspect.html"
|
||||
But I should not see "{{ page | inspect }}" in "_site/inspect.html"
|
||||
But I should see "{% include inspector.html %}" in "_site/inspect.html"
|
||||
|
|
|
@ -59,13 +59,6 @@ Gem::Specification.new do |s|
|
|||
* Our `post_url` tag now comes with the `relative_url` filter incorporated into it.
|
||||
You shouldn't prepend `{{ site.baseurl }}` to `{% post_url 2019-03-27-hello %}`
|
||||
For further details: https://github.com/jekyll/jekyll/pull/7589
|
||||
|
||||
* Our `highlight` tag no longer parses Liquid and Liquid-like constructs in the
|
||||
tag's content body. While this means you no longer need to enclose the content
|
||||
within a `{% raw %}{% endraw %}` block, it also means that you can no longer
|
||||
do the following as well:
|
||||
`{% highlight html %}{% include snippet.html %}{% endhighlight %}`
|
||||
For further details: https://github.com/jekyll/jekyll/pull/6821
|
||||
----------------------------------------------------------------------------------
|
||||
MSG
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module Jekyll
|
||||
module Tags
|
||||
class HighlightBlock < Liquid::Raw
|
||||
class HighlightBlock < Liquid::Block
|
||||
include Liquid::StandardFilters
|
||||
|
||||
# The regular expression syntax checker. Start with the language specifier.
|
||||
|
@ -33,7 +33,7 @@ module Jekyll
|
|||
def render(context)
|
||||
prefix = context["highlighter_prefix"] || ""
|
||||
suffix = context["highlighter_suffix"] || ""
|
||||
code = @body.gsub(LEADING_OR_TRAILING_LINE_TERMINATORS, "")
|
||||
code = super.to_s.gsub(LEADING_OR_TRAILING_LINE_TERMINATORS, "")
|
||||
|
||||
output =
|
||||
case context.registers[:site].highlighter
|
||||
|
@ -103,8 +103,6 @@ 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
|
||||
|
|
|
@ -69,30 +69,6 @@ class TestTags < JekyllUnitTest
|
|||
end
|
||||
end
|
||||
|
||||
context "highlight tag" do
|
||||
setup do
|
||||
create_post <<~CONTENT
|
||||
---
|
||||
title: This is a test
|
||||
---
|
||||
|
||||
This is not yet highlighted
|
||||
|
||||
{% highlight html %}
|
||||
<h1>{% unregistered_tag %}</h1>
|
||||
{{ page | inspect }}
|
||||
{% endhighlight %}
|
||||
|
||||
This should not be highlighted, right?
|
||||
CONTENT
|
||||
end
|
||||
|
||||
should "not parse Liquid constructs in the tag markup" do
|
||||
assert_match "{% unregistered_tag %}", @result
|
||||
assert_match "{{ page | inspect }}", @result
|
||||
end
|
||||
end
|
||||
|
||||
context "highlight tag in unsafe mode" do
|
||||
should "set the no options with just a language name" do
|
||||
tag = highlight_block_with_opts("ruby ")
|
||||
|
|
Loading…
Reference in New Issue