Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Syntax highlighting not working with Markdown Extra

Started by Muut Archive 10 years ago · 4 replies · 1139 views
10 years ago

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!

10 years ago

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
<?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.

10 years ago

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.

10 years ago

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

thanks!

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1366 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1125 9 years ago