@illionas I think this is still less natural than just using HTML code blocks, but I think this is definitely better because it’s robust against modifying the code (i.e.: adding or removing lines).
I think just using code blocks in HTML is the best solution to this. Needing to substitute <
with <
only seems to be necessary for things that look like HTML tags (e.g.: #include <iostream>
, but not x < 0
: https://goo.gl/Yj8J9v). Obviously the worst case would be trying to markup an HTML code snippet, but for most languages I think it won’t be too onerous.
The only issue I see (and I’m not sure if this is a bug or WAI) is that a newline after <pre><code>
get interpreted as part of the code block, so you need to put the first line of your code block on the same line as <pre><code>
(see again the link above).