-
Notifications
You must be signed in to change notification settings - Fork 42
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
Nested <pre> tags cause output errors #71
Comments
Could you provide the uncompressed output HTML? Most likely it's because highlighting is wrapped in a |
I auditioned with a simple Jekyll project: |
I can confirm this is because of the HTML collapses whitespace by default, the For reference, here's what it would look like if we collapsed that part like you asked: You can read more about pre and white-space on MDN. |
Ah, it seems I misunderstood - when doing a "Double highlight" like that you get nested pre tags - that's something we haven't implemented (Because I never thought I'd actually see them in the wild) It seems more like a bug in the highlighter but I'll take a look |
Exactly, that's it. thank you |
@williamcanin I know from experience that getting nested anything to work in liquid is really really hard so I wouldn't expect this to get done any time soon if I were you. Instead it might be more productive to tweak Jekyll itself at
|
Thanks for the sugestion. I will do that. |
I have the same issue with rouge highlighter, the "linenos" breaks html output. Yep, rouge doubles "pre" tags. But it is the only way now on github's servers... |
Workaround to avoid this bug. Initially you have the code like:
Change it to:
_include/fixlinenos.html content:
|
So, will be any fixes in this project? |
Probably not going to happen. Nested pre tags don't usually happen in manmade html, and using a depth counter would at least triple build times |
@jnvsor OK, I have inserted hack by @DeXP to jekyll source ( rendered_output = add_code_tag(output)
# FIX start: remove double pre
if rendered_output.include? "<pre class=\"lineno\""
rendered_output.gsub!("<pre><code ", "<div class=\"code-wrap\"><code ")
rendered_output.gsub!("</code></pre>", "</code></div>")
end
# FIX end
prefix + rendered_output + suffix and them in every CSS file add Works absolutely perfect. |
Great. Though if you're at the point where you're modifying jekyll source perhaps you'd be better with a dedicated build platform like Grunt or Gulp and a dedicated HTML minifier |
@jnvsor No, I'm just too lazy to write any new code or use new tools, so editing locally installed Jekyll seems fine) |
Netlify is gzipping everything for us anyway, so I don't think this is saving many bytes, whereas it is breaking highlighted code/json: penibelst/jekyll-compress-html#71
First, congratulations for the plugin.
Next, when using "linenos" the highlight ...
Example:
{% highlight ruby linenos %}
... my block that is between the "highlight" is not compressed properly in html.
The question is whether there is configuration to work around this problem or if this is a weak point in the plugin.
Thanks
The text was updated successfully, but these errors were encountered: