4
votes

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>
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 works; using the Gemfile with the github-pages gem pins the version of Jekyll to 3.0.3).matt
That explains it. Knowing that, I uninstalled everything and reset my installation from the github-pages dependencies and it works fine. Thanks!Nicolas Rinaudo
I had a look into this, and it looks like it is actually fixed in Jekyll master; see github.com/jekyll/jekyll/issues/4427 and github.com/jekyll/jekyll/commit/… , 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

1 Answers

4
votes

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?