I've installed Orchard 1.7.0, enabled markdown for blog posts (roughly as detailed here) but I'm unable to figure out how to add syntax highlighting for C# (or any language) to my posts.
To highlight code, write the name of the language the code is written in after the initial triple backticks. In the above example, the code is written in JavaScript, and hence javascript is added after triple backticks.
Many Markdown processors support syntax highlighting for fenced code blocks. This feature allows you to add color highlighting for whatever language your code was written in. To add syntax highlighting, specify a language next to the backticks before the fenced code block.
Syntax highlighting is one strategy to improve the readability and context of the text; especially for code that spans several pages. The reader can easily ignore large sections of comments or code, depending on what they are looking for. Syntax highlighting also helps programmers find errors in their program.
StackExchange uses Google Code Prettify (see here) and there is an Orchard module TheMonarch.SyntaxHighlighter that sets this up.
This module uses Google code prettify to add syntax highlighting to Orchard Blog posts. Choose from several themes bundled from the Admin UI. Google code prettify automatically detects most languages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With