4

I'm trying to get some very simple pages to render properly with Jekyll using kramdown to process markdown and rouge for syntax highlighting. Kramdown appears to not interpret triple-backticks, however, even in GFM mode.

I believe I've followed the instructions to the letter, and things work out fine when pushed to github pages, but my local setup just ignores the backticks.

If it's any help, this has been observed on OS X with Jekyll 3.1.1. The command line used to invoke jekyll is jekyll serve --config "_config.yml".

I've narrowed the problem to the following minimal test:

_config.yml

markdown: kramdown
highlighter: rouge

kramdown:
  input: GFM

index.md

---
layout: default
---

```scala
def test(i: Int): Unit = {
  println(i)
}

```

layout/default.html

<!doctype html>
<html>
  <body>{{ content }}</body>
</html>

Resulting index.html

<!doctype html>
<html>
  <body><p>```scala
def test(i: Int): Unit = {
  println(i)
}</p>

<p>```</p>
</body>
</html>
Nicolas Rinaudo
  • 6,068
  • 28
  • 41
  • 1
    I managed to reproduce this. There seems to be a bug with Jekyll 3.1.1 where it doesn’t respect the `input` configuration option so isn’t using GFM. Jekyll 3.0.3 works though (which is why the [answer below](http://stackoverflow.com/a/35348119/214790) works; using the `Gemfile` with the `github-pages` gem pins the version of Jekyll to 3.0.3). – matt Feb 11 '16 at 20:36
  • That explains it. Knowing that, I uninstalled everything and reset my installation from the `github-pages` dependencies and it works fine. Thanks! – Nicolas Rinaudo Feb 11 '16 at 20:38
  • I had a look into this, and it looks like it is actually fixed in Jekyll master; see https://github.com/jekyll/jekyll/issues/4427 and https://github.com/jekyll/jekyll/commit/4d805e29bc4b1c0df1bf6a44b00331de90643f27 , so should be working in the next release. Since you’re using Github pages, you’re probably better off sticking with the solution you have though. – matt Feb 11 '16 at 22:38

1 Answers1

4

I suggest you to do like this. I tested your code block whit the following configuration and it worked fine:

config.yml :

highlighter: rouge
markdown: kramdown
kramdown:
  input: GFM

Then, to your file index.md:

```scala
def test(i: Int): Unit = {
   println(i)
 }
```

Note: I've noticed that there was a space before ```scala and it shouldn't be there.

Then, run jekyll serve with bundler:

Open your terminal and:

  1. Install bundler: gem install bundler

  2. Update all your gems (if you want): bundle update

  3. Add a Gemfile (don't add any file extension) to your site root and paste the code below into it. This is GitHub Pages recommended method.

    source 'https://rubygems.org'
    
    gem 'github-pages'
    
  4. Go to your project root folder (on the terminal) and run: bundle install (this will make sure you have all required gems and their dependencies installed locally). A Gemfile.lock will be generated for you at your site root. Leave it there.

  5. Run bundle exec jekyll serve --watch to view your site locally at http://localhost:4000

Done!

Let me know if this works for you, yeah?

Virtua Creative
  • 2,025
  • 1
  • 13
  • 18
  • That worked perfectly, thank you very much! Since my site is generated dynamically, I still need to work out how to do what you just suggested, but system wide, but your answer is exactly what I needed. Thanks! – Nicolas Rinaudo Feb 11 '16 at 20:14
  • Great! I'm glad to have helped! :) if you need something else, we're here to help! ;) – Virtua Creative Feb 11 '16 at 20:18
  • This does not appear to work for single backtick inline code e.g. `foo` – nietras May 25 '20 at 14:39