Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclosed rouge highlighting #4432

Closed
tomasfejfar opened this issue Jan 31, 2016 · 17 comments
Closed

Unclosed rouge highlighting #4432

tomasfejfar opened this issue Jan 31, 2016 · 17 comments

Comments

@tomasfejfar
Copy link
Contributor

I have a post:

---
layout: post
status: publish
published: true
title: This blog is now on Jekyll
date: '2016-01-31 00:00:00 +0200'
tags: []
excerpt: Some excerpt

---
This is not yet highlighted
{% highlight php linenos %}
test
{% endhighlight %}

This should not be highlighted, right? 

And it generates this:
image

Actual HTML:

<p>This is not yet highlighted</p>

<div class="highlight"><pre><code class="language-php" data-lang="php">
    <table style="border-spacing: 0">
        <tbody>
        <tr>
            <td class="gutter gl" style="text-align: right">
                <pre class="lineno">1</pre>
            </td>
            <td class="code"><pre>test<span class="w"></span></pre>
            </td>
        </tr>
        </tbody>
    </table>


    This should not be highlighted, right?
</code></pre>
</div>

      <hr>

My config (relevant part):

permalink:   /:title/
markdown:    kramdown
highlighter: rouge
sass:
  sass_dir: _sass
  style: compressed
gems:
  - jekyll-sitemap

kramdown:

  auto_ids: true
  footnote_nr: 1
  entity_output: as_char
  toc_levels: 1..6
  enable_coderay: false
  syntax_highlighter: rouge
  line_numbers: true

Could this be theme issue? And if so, how could I debug it? It seems to me like a problem in parsing the closing endhighlight tag...

@tomasfejfar
Copy link
Contributor Author

I just noticed that it's rendered correctly if I remove the linenos from the highlight tag. Am I doing it wrong?

@parkr
Copy link
Member

parkr commented Feb 1, 2016

If you inspect the element and futz around with the CSS, is it fixable by modifying the CSS?

@tomasfejfar
Copy link
Contributor Author

I updated the first post with reformated HTML to make it more obvious. The problem is that the generated HTML does not close the <div class="highlight"><pre><code class="language-php" data-lang="php"> soon enough. It contains the content that was BELOW the {% endhighlight %} in the MD file.

@parkr parkr added the bug label Feb 2, 2016
@oapdf1
Copy link

oapdf1 commented Feb 4, 2016

I have to update my blog in Github page from pygment to rouge today. I also meet this bug when I used the linenos option. The last highlight block by {% highlight vb linenos %} will end </div> at wrong place.
BTW, can rouge unify the format for `````....```` and {% highlight vb %} tag?
The previous one format as:
`

`
and the later one is:
`
`.
The later one is similar to that in pygment and I don't need to modify my css ( I have to setup the background color ...). Now I have to set up the style in both formats... :(

@parkr
Copy link
Member

parkr commented Feb 5, 2016

This looks to me like a strange liquid parsing issue. Could you open a PR with a failing test cases for this inside of test/test_tags.rb in the highlighting section? Then we can go from there to find a fix.

@tomasfejfar
Copy link
Contributor Author

@parkr see the mentioned PR - I thought that there there is Travis here or something. I tried running the tests locally, but it does not seem to work as per instructions in CONTRIBUTING.markdown. I'm trying to do it on Windows which is probably not the best choice :( It tries to run bash shell, which I havent got ruby set up in and I try not to mess with it as I need it for other, non-ruby projects.

@tomasfejfar
Copy link
Contributor Author

Full blog code here: https://github.com/tomasfejfar/blog

@jekyllbot
Copy link
Contributor

This issue has been automatically marked as stale because it has not been commented on for at least
three months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If you can still reproduce this error on the 3.1-stable or master branch,
please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider building it first as a plugin. Jekyll 3 introduced
hooks which provide convenient access points throughout
the Jekyll build pipeline whereby most needs can be fulfilled. If this is something that cannot be
built as a plugin, then please provide more information about why in order to keep this issue open.

Thank you for all your contributions.

@jekyllbot jekyllbot added the stale Nobody stepped up to work on this issue. label Jun 6, 2016
@oddlyfunctional
Copy link

Any news? This is also happening to me.

@jekyllbot jekyllbot removed the stale Nobody stepped up to work on this issue. label Sep 20, 2016
@pschfr
Copy link

pschfr commented Aug 23, 2017

I still face this too :(

@DirtyF
Copy link
Member

DirtyF commented Aug 24, 2017

Far anyone experiencing this issue, could you confirm that it works with latest release of Jekyll who provides support for Rouge 2 and Liquid 4 ?

gem install jekyll
bundle update
bundle exec jekyll serve

For my test case I didn't touch the default _config.ymlof jekyll new, I just added lineos option to the default post:

{% highlight ruby linenos %}
def print_hi(name)
  puts "Hi, #{name}"
end
print_hi('Tom')
#=> prints 'Hi, Tom' to STDOUT.
{% endhighlight %}

{% highlight php linenos %}
<?php phpinfo(); ?>
{% endhighlight %}

Code blocks are properly highlighted with line numbers:

lineos-jekyll

@omniproc
Copy link

omniproc commented Jan 21, 2018

@DirtyF it's still happening to me. But in my case it seems related to this issue with jekyll-compress-html.

@ghost
Copy link

ghost commented Jan 21, 2018

@M451 what version of jekyll are you on? if it's the latest one, could you open a new issue?

@DirtyF
Copy link
Member

DirtyF commented Jan 21, 2018

@M451 and if you don't use the compress layout in base layout?

@DirtyF
Copy link
Member

DirtyF commented Jan 21, 2018

Consider this resolved as when testing with latest Jekyll and the original post example, rendering is fine with default theme:

test-4432

@omniproc
Copy link

omniproc commented Jan 21, 2018

@DirtyF it doesn't happen when I don't use the compress layout. Thus for now I've thrown that out.
@pup I've tested this with jekyll 3.6.2 and it was happening with the latest (todays) github-pages gem on github pages as well.

But I believe it's more a issue with the compress layout rather then Jekyll per-se.

@DirtyF
Copy link
Member

DirtyF commented Jan 21, 2018

@M451 Instead of the compress layout, you can give a try to jekyll-tidy plugin who has a html compression option.

@jekyll jekyll locked and limited conversation to collaborators Jul 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants