6

Using kramdown and rouge for markdown syntax-highlighting in a jekyll blog, I'd like to prevent long lines of code from wrapping onto a new line. I'd like to be able to use a horizontal scrollbar to reveal the rest of the content.

Here is the jekyll config:

markdown: kramdown
kramdown:
  input: GFM
  syntax_highlighter: rouge

I'm using the base16.solarized.dark css theme generated by the rougify command.

Here is an example code usage:

```` js
console.log("some code") // and a really really long long long comment which i'd like to not wrap onto the next line
````
s2t2
  • 2,462
  • 5
  • 37
  • 47
  • Impossible to debug without seeing your css stack. Can you provide a repository link ? – David Jacquel Apr 14 '16 at 09:09
  • https://github.com/data-creative/data-creative.github.io/ using twitter bootstrap and base16.solarized.dark for css - thanks! – s2t2 Apr 14 '16 at 13:37

3 Answers3

7

Boostrap is adding a white-space: pre-wrap rule in order to help code block readability.

If you want you code block to avoid this wrap, you can edit your css/data-creative.css and add

pre code{
  white-space: pre;
}
David Jacquel
  • 51,670
  • 6
  • 121
  • 147
  • I tried setting this property before but maybe I was applying it on the wrong element/ set of elements. Thank you! – s2t2 Apr 15 '16 at 00:13
2

You have somewhere a CSS rule that for the code element sets white-space: pre-wrap. Add the following rule to override it:

code {
    white-space: pre;
}
Alex Palcuie
  • 4,434
  • 3
  • 22
  • 27
2

I solved it like this:

pre {
    ...
    overflow-x: scroll;
}
Yunnosch
  • 26,130
  • 9
  • 42
  • 54