Skip to content
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

Inline code broken with Rouge and line numbers #286

reitzig opened this issue Sep 24, 2015 · 5 comments

Inline code broken with Rouge and line numbers #286

reitzig opened this issue Sep 24, 2015 · 5 comments


Copy link

reitzig commented Sep 24, 2015

I use kramdown with Rouge in my Jekyll site.

I notice that kramdown compiles inline code to <code class="highlighter-rouge">inline code</code> instead of simply <code>...</code>. While it would be nice to be able to turn off highlighting in inline code, no biggy.

When I set line_numbers: true, however, things get ugly: Rouge can or does not distinguish between inline and block code, and translates the inline code into a block with line numbers -- clearly not as intended!

(The created code looks broken beyond that, too.)

@gettalong gettalong self-assigned this Sep 26, 2015
Copy link

Thanks for reporting this!

To mitigate the problem I have implemented the following changes:

  • Globally enabling rouge as syntax highlighter and disabling span and/or block highlighting is now possible by using the new "disable" option.
  • Options can now be set for both spans and blocks as well as only for spans or only for blocks. This enables you to turn on the line numbers for blocks but not for spans.

reitzig added a commit to reitzig/ that referenced this issue Sep 28, 2015
 * Turns off line numbers in code for now;
	cf. gettalong/kramdown#286
 * Changes feed.xml to show only an excerpt;
	MathJax and tricky don't work there.
 * Introduces a plugin that nicely typsets (La)TeX.
 * Fixes some abstracts in the .bib file to compile properly.
 * Changes bibliography details template so that Markdown in
	abstracts is compiled.
 * Adds a page option for enabling MathJax.
 * Adds tags next to date for posts; printing of this moved to
	a plugin for reusability.
 * marginnote plugin was missing a space.
 * Changes syntax highlighting CSS so it works with
	and without line numbers.
 * Adds styling of <hr> in articles.
 * Fixes weird font in sidenotes, and line height in
	side- and marginnote both.
 * Footnotes now indent a bit, and break similarly to the rest
	of the page.
Copy link

tdbe commented Nov 18, 2016

using the new "disable" option

Options can now be set for both spans and blocks as well as only for spans or only for blocks

Could you please provide a usage example of what that syntax looks like in the _config.yml file?

All I understood is that you now have that capability and flexibility. But how exactly do I fix the inline code while having line_numbers: true on the code blocks?

Copy link

kramdown doesn't have a _config.yml file. You need to use the 'syntax_highligher_opts' configuration option as described on the documentation page for the rouge syntax highlighter.

Where you set this option depends on how use kramdown, e.g. if you are using the binary, you would do something like the following:

kramdown --syntax-highlighter rouge --syntax-highlighter-opts "{span: {disable: true}}"

Copy link

tdbe commented Nov 18, 2016

Oh I see where you're coming from but I was referring to the OP's context, ie using Jekyll with github's builtin markdown compilers. But thanks for the docs links.

[UPDATE] For future reference, I found the solution for what you need to write in your _config.yml file for Github + Jekyll + Rouge:

  input:          GFM
  syntax_highlighter: rouge

  # Rouge Highlighter in Kramdown ›
  # span, block element options fall back to global
    # Rouge Options ›
    css_class: 'highlight'
    #line_numbers: true # bad idea, spans don't need linenos and would inherit this option
      line_numbers: false
      line_numbers: true
      start_line: 1

Copy link

Please ask the Jekyll team - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants