Code blocks and backslashes

John Gruber gruber at fedora.net
Fri Nov 5 19:40:07 EST 2004


Mark Lawrence <lawrence at unified-eng.com> wrote on 11/01/04 at 11:20am:

> Tracing the code, I find that the _EncodeBackslashEscapes subroutine is
> the culprit. It's called by _EscapeSpecialChars, which, in turn, is
> called by Markdown just before _RunBlockGamut. _EncodeBackslashEscapes
> makes 13 transformations of backslash sequences, including \\.
> 
> This means that code blocks that include any of those 13 character
> sequences have to be altered, adding extra backslashes. I think this
> contradicts the basic idea of having the HTML version and the text
> version look the same. It also increases the likelihood of errors in
> code blocks and prevents the straightforward cutting and pasting of
> working code.

I agree with both complaints -- that it's un-Markdown-ish and likely
to cause unexpected errors. Actually, that's probably just two ways
of saying the same thing -- the errors are unexpected because one
doesn't expect Markdown to work that way.

I can't remember the reason why Markdown.pl is doing this. I'll log
it for attention, and see if there isn't some way to process code
blocks such that they are always taken literally.

-J.G.


More information about the Markdown-discuss mailing list