mojombo/jekyll — Issue #418: Markdown pygments_prefix and pygments_suffix ("\n") breaks layout
Author: madebydna
Created: 2011-10-17 14:54:32+00:00
State: open

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:

code inside blockquote

git add .

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:

Clone your new repo:

......

Add the upstream remote:

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