Code blocks and backslashes
Mark Lawrence
lawrence at unified-eng.com
Mon Nov 1 12:20:47 EST 2004
I've run across a problem with code blocks not being literal when the
code contains certain backslash sequences. I had a code block that
contained the line
\\l'3.5i'
(it's part of a Perl here-document that's writing out troff code). When
Markdown created the HTML, the double-backslash was converted to single.
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 haven't spent enough time with the Markdown code to have a good feel
for its flow, but I wonder if _EncodeCode could be altered to reverse
the effects of _EncodeBackslashEscapes.
I'm new to the list, so I apologize if this has been discussed before. I
looked in the archives, but found no threads that were obviously on this
topic.
--
Look at a very small object, look at its centre.
-- Eno & Schmidt, Oblique Strategies
More information about the Markdown-discuss
mailing list