Skip to content
Permalink
Browse files

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 36404b9.

* use Liquid `raw` in upgrading document
* let the minor improvements stay
* Revert entry in History.markdown
  • Loading branch information...
ashmaroli committed Apr 19, 2019
1 parent 36d3aed commit f4ee82650efebb2d37acf3493398f0e4e99b31b3
Showing with 4 additions and 80 deletions.
  1. +0 −1 History.markdown
  2. +2 −0 docs/_docs/upgrading/3-to-4.md
  3. +0 −44 features/highlighting.feature
  4. +0 −7 jekyll.gemspec
  5. +2 −4 lib/jekyll/tags/highlight.rb
  6. +0 −24 test/test_tags.rb
@@ -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 @@ def initialize(tag_name, markup, tokens)
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 @@ def add_code_tag(code)
"<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 @@ def highlight_block_with_opts(options_string)
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 ")

0 comments on commit f4ee826

Please sign in to comment.
You can’t perform that action at this time.