Search code examples
markdownjekyllgithub-pages

Code not highlighted on github pages markdown


I created a github page, using jekyll's minimal theme

I'm writing the pages in markdown. In my _config.yml file, I have the options :

markdown: kramdown
highlighter: rouge
kramdown:
    input: GFM
    syntax_highlighter: rouge

Somehow, the code is however not highlighted : https://sergedmi.github.io/pages/arccos

Note that the minimal theme does contain a css stylesheet that should highlight the code according to rouge markup.

The code is correctly highlighted in github : https://github.com/SergeDmi/SergeDmi.github.io/blob/master/pages/arccos.md

Any tip ?


Solution

  • Updated Answer

    I am confident that the fix is to change C++ to cpp in your Markdown code blocks.

    Here is how I tested the fix.

    1. jekyll new cpp-test
    2. Add the configuration to the auto-generated _config.yml to use rouge for code block syntax highlighting.
    markdown: kramdown
    highlighter: rouge
    kramdown:
        input: GFM
        syntax_highlighter: rouge
    
    1. Run jekyll s in new cpp-test directory

    Rendering

    Here is what it looks like with C++ C++ example

    Here is what it looks like with cpp ccp example

    Original Answer

    Could it be that you need to use cpp instead of C++ in your Markdown code blocks?

    It looks like GitHub will syntax highlight your code blocks the same if you switch C++ to cpp.

    Rouge documents C++ as cpp here https://github.com/rouge-ruby/rouge/blob/master/docs/Languages.md.