Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 449
SergeD Avatar asked Oct 25 '25 17:10

SergeD


1 Answers

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.

like image 170
Kin Avatar answered Oct 27 '25 14:10

Kin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!