5
$\begingroup$

I recently submitted an edit to Another notion of exactness: how to refine it, and where does it fit? to replace hand-rolled commutative diagrams with AMScds, since it had popped up on the front page. After my edit, but not before, things like **Example** were rendered literally, rather than in boldface. This was obviously incorrect, so, in the absence of an understanding of why, I thought that I had better roll back to version 9. I did, but to no avail:

Example should be italicised

I would like to know why this happened, but much more I would like to get rid of my inadvertent vandalism, which rolling back did not suffice to do. I have flagged the post for moderator attention. What else should or can I do?

$\endgroup$

2 Answers 2

6
$\begingroup$

The post "HTML comments break formatting from that point" on Meta Stack Exchange mentions that problems can be caused by an incorrectly entered HTML comment

<!-- An HTML comment --!>

instead of the correct version

<!-- An HTML comment -->

As far as I can tell, after revision 12 when I changed exactly this, Markdown seems to be rendered correctly.

When I try searching in the MarkDown code for other similar mistakes here on MO, the SEDE query returns only this post. (And after the next update of the database, it should no longer be in the result.) Searching in the body returns nothing.

Below you can see a few "experiments" testing how this behaves when posted here.


This is the text from the linked post, but it is not commented - notice that the italics work here:

  1. for any span $C\xleftarrow{g}A\xrightarrow{f}B$, there is—up to isomorphism—at most one exact square containing it, and similarly for any cospan $C\xrightarrow{i}D\xleftarrow{h}B$. ---- This rules out the van Kampen example, so I erased it.

We refer to a category with an exactness structure as an exacting category. We say that a functor is exacting if it preserves initial objects and exact squares.


And now the same text as a comment - with correct version of HTML comment:

We refer to a category with an exactness structure as an exacting category. We say that a functor is exacting if it preserves initial objects and exact squares.


And this happens, if I use HTML commenting in the same way as in revision 11 of the post.

We refer to a category with an exactness structure as an *exacting category*. We say that a functor is *exacting* if it preserves initial objects and exact squares.
$\endgroup$
11
  • $\begingroup$ That definitely seems to be it, thanks! Do you know why it didn't break before, at revision 9? (This cannot be verified now, since viewing that version still shows the broken formatting, but it definitely wasn't there before I edited.) $\endgroup$
    – LSpice
    Commented Jun 30, 2023 at 1:33
  • 1
    $\begingroup$ Indeed, the version shown in the Wayback Machine on 8 June 2023 seems to be OK. I don't really know why the problem didn't appear before, but I will point out that the post was created before switching to CommonMark. $\endgroup$ Commented Jun 30, 2023 at 4:25
  • 1
    $\begingroup$ There is no such thing as HTML comments as far as the Markdown parser is concerned. See meta.stackexchange.com/a/135909 . They are just treated as invalid HTML tags, and as such removed from the output. You can get exactly the same behaviour by formatting “comments” as <comment ... >, <asdfg ... >, or whatever else of that sort. $\endgroup$ Commented Jun 30, 2023 at 5:05
  • 1
    $\begingroup$ @EmilJeřábek, re, and yet changing <!-- --!> to <!-- -->, and nothing else, did fix it, so, whether it's because of parsing it as a comment (as you point out it isn't) or for any other reason, it seems hard to doubt that that that was the cause. Nonetheless, @‍MartinSleziak has asked me to unaccept this answer so that other people will be encouraged to weigh in, so I have done so. $\endgroup$
    – LSpice
    Commented Jun 30, 2023 at 13:45
  • $\begingroup$ @LSpice I do not doubt that the change worked. I’m just complaining that the explanation is misleading the reader into thinking that the parser supports a well-defined comment syntax. It does not, and the fact that some versions of it appear to work, and some do not, is accidental. $\endgroup$ Commented Jun 30, 2023 at 13:53
  • $\begingroup$ @EmilJeřábek, re, I have posted a sandbox answer. While I trust you when you say that Markdown does not obey any notion of comments, something like <comment Discarded> disappears; <comment !> and <comment --!> stay in the rendered post but do not trip the bug; and <!-- --!> disappears but triggers the bug—so there is something different about !-- at the beginning and/or ! at the end. $\endgroup$
    – LSpice
    Commented Jun 30, 2023 at 14:35
  • 1
    $\begingroup$ Re, in fact it seems that a tag starting with a <!-- must be terminated with --> in order not to stop formatting. For example, <!--> is OK, but <!-- >, <!-- Discarded>, and <!-- -> all stop formatting. $\endgroup$
    – LSpice
    Commented Jun 30, 2023 at 14:44
  • $\begingroup$ @LSpice Please read meta.stackexchange.com/questions/1777/… closely. The parser recognizes some expressions that conform to the syntax of HTML comments for special purposes, such as declaration of a language for syntax highlighting. Presumably, it parses such things by first trying to match <!-- ... --> and then deciphering the ... part, which means that <!-- not terminated by a --> will throw it off. Anyway, trying to reverse engineer what invalid inputs do or don’t trigger a bug is an exercise in futility. $\endgroup$ Commented Jun 30, 2023 at 15:03
  • $\begingroup$ @EmilJeřábek, re, sorry, I'm confused. It seems to me that you are saying that the parser attempts to recognise some comment-like things as comments. I don't understand how to reconcile that with saying "There is no such thing as HTML comments as far as the Markdown parser is concerned." $\endgroup$
    – LSpice
    Commented Jun 30, 2023 at 16:57
  • 1
    $\begingroup$ Maybe you just meant "calling this an issue with HTML comments" is not literally, technically correct. But what you are saying sounds to me consonant with what I took to be the spirit of @‍MartinSleziak's answer. I'm not sure I agree that figuring out what invalid inputs do or don't trigger a bug is an exercise in futility; it seems to me the very spirit embodied in fuzzing. $\endgroup$
    – LSpice
    Commented Jun 30, 2023 at 16:59
  • $\begingroup$ I am saying that the parser recognizes some comment-like things as other things, not as comments. $\endgroup$ Commented Jun 30, 2023 at 17:04
1
$\begingroup$

A sandbox for testing. If you update this, please update the indented block as well as the non-indented block.

<!>

*Italics*

<comment !>

*Italics*

<comment --!>

*Italics*

<comment Discarded>

*Italics*

<comment -->

*Italics*

<!-->

*Italics*

<!-- ->

*No italics*

<!-- >

*No italics*, even if re-ordered

<!-- !>

*No italics*, even if re-ordered

<!-- Discarded>

*No italics*, even if re-ordered

<!-- --!>

*No italics*, even if re-ordered

<!>

Italics

<comment !>

Italics

<comment --!>

Italics

Italics

<comment -->

Italics

Italics

*No italics* *No italics*, even if re-ordered *No italics*, even if re-ordered *No italics*, even if re-ordered *No italics*, even if re-ordered
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .