3
\$\begingroup\$

Is there a way to highlight code syntax in a <pre> block?

In this post, I had originally inserted my code using a <pre> block, but the code was not highlighted. After indenting every line by four characters the highlighting worked. I would include an example here, but I couldn't get highlighting to work on Code Review Meta.

\$\endgroup\$
8
\$\begingroup\$

The highlighting will work if you use <pre><code> instead of just <pre>.

However it is preferred that you use the regular markdown syntax for code samples (i.e. indent by four spaces). There's a button in the formatting toolbar (the one with the {}) as well as a keyboard shortcut (ctrl+k) to do this for you, so you don't need to indent every line by hand.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .