Syntax highlighting not working with Markdown Extra

Hi I’m new to Grav. I just got setup with the default Antimatter theme. I was reading through the tutorial and it seems like syntax highlighting should work if I enable Markdown extra in system.yaml. After setting extra: true and using the backquote syntax it doesn’t seem to work. The code just blockquoted and no highlighting is applied. Is there some other step I need to do to enable syntax highlighting other than enabling markdown extra in config?

I tried setting extra: true to both system.yaml in system and user folder. Either case didn’t work

thanks!

Hi @nahh,

Markdown Extra doesn’t highlight code for you. The only thing what it does, is setting the appropriate classes. Usually you write something like

``php
<?php phpinfo();
``

(with three instead of two backticks of course). On top of that you need a syntax highlighter. Highlight uses for example the well known Highlight.js. If you want to process the code with PHP you can do so for example with Geshi, but there is no plugin yet, so that you have to write it on your own.

Hello,
I’m refering to this https://learn.getgrav.org/content/markdown#syntax-highlighting

I might be missing something but from the documentation it seems like it is supported out of the box as long as Markdown Extra is enabled?

I also tried highlight.js it did the exact same thing, no highlight just fences the code.

The documentation you referred is indeed unclear, but in order to highlight code (inside fenced code) you need the Highlight plugin (https://github.com/getgrav/grav-plugin-highlight) I mentioned earlier. Further, on the client side JavaScript must be enabled. Without you only see the non-highlighted code.

i just got highlight.js plugin to work. Weird it wasn’t working yesterday

thanks!