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

Already on GitHub? Sign in to your account

Markdown pygments_prefix and pygments_suffix ("\n") breaks layout #418

madebydna opened this Issue Oct 17, 2011 · 1 comment


None yet
3 participants

The Jekyll::MarkdownConverter class sets the default pyments_prefix and pyments_suffix to be a line break. This causes line breaks to be prepended/appended to the code block contained in highlight tags.

As a consequence, the Markdown layout breaks in some places where indentation has a specific role, like for example in code blocks that reside within blockquotes or within nested list items.

So this Markdown:

> code inside blockquote {% highlight bash %} git add .{% endhighlight %}

Gets rendered incorrectly as:

  <p>code inside blockquote</p>
<div class="highlight">
     <code class="bash">git add .</code>

Or in the case of an ordered list, for example:

 1. Clone your new repo:
      {% highlight bash %}
        git clone git@github.com:YOUR_NAME/ruby.git
      {% endhighlight %}

 2. Add the upstream remote:

Gets rendered as:

    <li>Clone your new repo:</li>
   <div class="highlight"> 
     <li>Add the upstream remote:</li>

Since the pygments_prefix and pygments_suffix are not configurable properties, the only way to override this behavior is to define one's own converter class as a Jekyll Plugin.

Before I submit a pull request, I was wondering if I could get some feedback on why the prefix and suffix variable default to line breaks. If there is no particular reason then it could make sense to set it to nil, which would fix the issues I mentioned and, as far as I can tell, would have no negative consequences. On the other hand, it might be better to just make the pygments_prefix and pygments_suffix configurable, which would also be fairly easy to do.

Let me know what you think would be the right approach to solve this problem and I'd be happy to submit a pull request with a fix.

~ Andrea


parkr commented Mar 19, 2013

I think you'd have to check with Pygments and pygments.rb about those prefix and suffix questions.

Please submit a PR - I'd be happy to review it!

@parkr parkr closed this Mar 19, 2013

@jekyllbot jekyllbot locked and limited conversation to collaborators Feb 27, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.