How to use code syntax highlighting with markdown?

Added by T H almost 7 years ago

I have Markdown enabled as my formatting style. It allows me to use fenced code blocks (surrounded by three backticks ```). This results in a

<pre>…</pre>
section being inserted into the resulting html. So far, so good. Now I would like to be able to style the code that’s inserted using either coderay or the highlightjs plugin. As far as I understand, using textile, I can simply say
<pre><code class="language">…</code>
to get highlighted code. However, using Markdown, I don’t know how to create the resulting html or highlighted source. Can anybody help?

Cheers
- ilpssun

Replies (2)

RE: How to use code syntax highlighting with markdown? - Added by Volker Kopetzky almost 7 years ago

You add the name of the language directly after your backticks.

```ruby
# some rube code
```

If this doesn't work for you, which redmine version are you using?

RE: How to use code syntax highlighting with markdown? - Added by T H almost 7 years ago

Ah, upon closer observation it seems to be working but not for language XML. Somehow, the XML-tags are passed to the browser and are being interpreted, i.e. swallowed, instead of being rendered.

Thanks anyway!
ilpssun

(1-2/2)