Kramdown backticks not recognized in GFM mode

817 Views Asked by At

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

There are 1 best solutions below

3
On BEST ANSWER

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?