Markdown strips leading and trailing whitespace in code spans:
http://code.google.com/p/pagedown/source/browse/Markdown.Converter.js#1011
http://code.google.com/p/markdownsharp/source/browse/MarkdownSharp/Markdown.cs#1358
The same is true for John Gruber's original Perl version. The comment before the function _DoCodeSpans
also explains why:
# * You can use spaces to get literal backticks at the edges:
#
# ... type `` `bar` `` ...
#
When you start a code span with, say, three backticks, you also have to end it with precisely three backticks. If the trailing whitespace was significant, it would be impossible to have a backtick at the end, since
```backtick: ````
is not a legal code span.
By the way, the reason that your <code><a </code>
doesn't display anything is simple: It's broken HTML. You're opening an <a>
tag, but you're not putting a closing angle bracket. So the sanitizer will remove the illegal HTML "tag" <a </code>
, and then the tag balancer will remove the opening <code>
tag, since it doesn't have a closing </code>
anymore.
When you write your own HTML, Markdown won't do any encoding for you; you'l have to replace <a
by <a
yourself:
foo <code><a </code> bar
-> foo <a
bar
foo <code><a </code> bar
-> foo <a
bar
Between the last two, note the tiny difference in whitespace after the code, resulting from the browser's whitespace condensing.