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

Add code tags to Pygments output #91

Closed
mokolabs opened this Issue Oct 23, 2009 · 2 comments

Comments

Projects
None yet
4 participants
@mokolabs
Contributor

mokolabs commented Oct 23, 2009

At present, when using Pygments to highlight code, your code is only wrapped in pre tags.

<div class="highlight">

<pre>

def hello
  puts "hello"

end
</pre>

</div>

Semantically, however, best practice is to first wrap code in <code> tags, with an optional class which contains the specific language used in the given code block. In fact, the HTML5 spec has adopted this practice and it will be part of the final specification.

<div class="highlight">

<pre>

<code class="ruby">

def hello
  puts "hello"

end
</code>

</pre>

</div>

Interestingly, when Pygments is not enabled, Jekyll will render code blocks using codehighlighter-style markup, which does include <code> tags correctly.

Here's a fork which updates Pygments output to include <code> tags and thus be more semantic and improve HTML5 compliance:

http://github.com/mokolabs/jekyll/tree/add_code_tags_to_pygment_output

(Ideally, this change should be pushed back to albino.rb, but since that's a core part of GitHub, mojombo and friends may be understandably slow to accept a patch on that.)

@shapeshed

This comment has been minimized.

shapeshed commented Oct 25, 2009

Nice work. I'm adding my support to have this patch integrated.

@mojombo

This comment has been minimized.

Contributor

mojombo commented Jan 9, 2010

Merged in master.

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

pointblack pushed a commit to pointblack/jekyll that referenced this issue Feb 3, 2018

This issue was closed.

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