Markdown comments
John Gruber
gruber at fedora.net
Tue Sep 19 02:21:32 EDT 2006
Michel Fortin <michel.fortin at michelf.com> wrote on 9/18/06 at 6:26 PM:
> But consider these two comments:
>
> <!------ Header ------->
>
> <!-- this -- or that -->
>
> Your proposal would change them to:
>
> <!--\-\-\-\- Header -\-\-\-\-\-->
>
> <!-- this -\- or that -->
My plain English rules were incomplete. I'm thinking the way it
would work is that the opening `<!--` and closing `-->` would be
treated separately; they're the "markers", the characters in
between are the comment.
However, XML forbids `--->` as a comment closer, so turning it
into `\--->` would still generate invalid XML output.
We need another rule that says that if a closing `-->` sequence is preceded by a `-`, there'll be a space inserted. So,
<!------ Header ------->
would turn into:
<!--\-\-\-\- Header -\-\-\-\- -->
> Beside not being particularly nice to read, a funny thing is that the
> first hyphen of the `-->` delimiter has to be "escaped", as you say
> it, which just seems strange. I think the backslash in this case
> should be called a separator, not an escape character.
The only other option is to allow people to create comments that
won't pass through an XML parser.
> I note that your backslash-"escape" method ensure that we are able to
> reconstruct the comment in its original form. Any reason this would
> be needed? If that's not needed then there is no need to escape
> already existing backslashes.
I can't think of a good reason, but I hate to destroy data. I
figure just because I think think of a good reason now to make
this transformation reversible doesn't mean I, or some other
Markdown user, won't think of one eventually.
> I think however that it is important is to keep things readable, and
> I'd prefer using something less distracting than a backslash as a
> separator. Using the same technique as shown above, spaces could be
> used as the separator instead of backslashes. Regexes like this:
[...]
> and it would still be possible to rebuild the original by removing
> exactly one space between each pair of hyphen.
Only if we add an extra space if you already have a space between
dashes in the input, right? I'm not opposed to using spaces
instead of backslashes.
> About commented scripts. This practice may not be recommended, it is
> still widely in use and I think we shouldn't break it. And since the
> Markdown syntax should not be processed within `<script>` tags, it
> should not "fix" comments there either, it's that simple.
Right, we shouldn't have to change anything for that.
I see HTML comments in script tags all the time when I view
source. I agree that it's wrong and bad practice for 2006, but
it's definitely common.
-J.G.
More information about the Markdown-Discuss
mailing list