jekyll: Pygments and the startinline option for PHP code blocks
In https://github.com/mojombo/jekyll/issues/31 an option startinline
was added to the Liquid tag so we can highlight PHP snippets without the <?php
tag:
<% highlight php startinline %>
Unfortunately, the triple backticks syntax has no way to inform this option.
As investigated by the discussion in this issue https://github.com/imathis/octopress/pull/1141, always turning on the startinline
option has no drawbacks, and it’s only used by the PHP lexer.
Maybe Jekyll could use it by default for redcarpet? It’s a one line change in lib/jekyll/converters/markdown/redcarpet_parser.rb
, resulting in the following:
Pygments.highlight(code, :lexer => lang, :options => { :encoding => 'utf-8', :startinline => true }),
Or maybe provide a global config such as:
pygments:
options: ['startinline']
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 16 (11 by maintainers)
Commits related to this issue
- Jekyll - fix highlighting php code https://github.com/jekyll/jekyll/issues/1633#issuecomment-238700179 — committed to EdgedesignCZ/phpqa by zdenekdrahos 8 years ago
This seems to be broken again, at least in Jekyll 3.1.6 and 3.2
I dumped these samples into a fresh jekyll project’s
index.html
:Works:
Doesn’t work:
Hmm… only seems to work if the markdown is not inside of html tags.
/sample.md
Markdown gets processed outside the
<div>
, but not inside. I attempted to{% include code_sample.md %}
inside of the div, but that didn’t change anything.We don’t support Pygments anymore. We use Rouge.