s2t2
s2t2

Reputation: 2686

Prevent line-wraps of code blocks using jekyll, kramdown, and rouge

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
````

Upvotes: 6

Views: 2360

Answers (3)

Enes Başpınar
Enes Başpınar

Reputation: 33

I solved it like this:

pre {
    ...
    overflow-x: scroll;
}

Upvotes: 2

David Jacquel
David Jacquel

Reputation: 52809

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;
}

Upvotes: 7

Alex Palcuie
Alex Palcuie

Reputation: 4974

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;
}

Upvotes: 2

Related Questions