On iOS HTML Comments Hit And Miss?

#1

I’ve been experimenting with using HTML comments to comment out blocks of Markdown. (And to add comments as Markdown doesn’t have its own syntax for that.)

I’m finding it unreliable - and experiments don’t quite tell me when it works and when it doesn’t.

Is anyone else seeing this?

(I’m on the latest TestFlight Beta on iOS.)

#2

It would be helpful if you provided example texts of what does and does and does not “work”.

If you want comments in your original content that are not in the published HTML, you might want to look at CriticMarkup support in MultiMarkdown. It has a comment syntax, {>> <<}.

#3

I’ll experiment on my flight home tomorrow.

#4

Strangely enough, attached to WiFi, I can’t reproduce the issues I had with HTML comments. Preview does indeed seem to hide what’s in the HTML comment bracketing. I don’t know that being connected has any bearing on the matter.

But CriticMarkup does something different: It seems to show what’s in the comment. I guess - reading their spec - the intent is highlight their comment differently from regular text.

I do think a preprocessor (before HTML rendering/preview) that strips out HTML comments in their entirety is useful. Now that I might work on on my flight home.

#5

And that I did work on on my flight home.

The following action takes the current draft’s content and replaces it with a version that has no HTML comments.

The core of it is a javascript function that can be repurposed.

One note: I originally tried to do it with regular expressions but couldn’t get the multi-line comment case to work.

One other note: I don’t know if it’s useful but part of the function is building an array of comment start and stop offsets. That would enable you to build a list of stripped out comments. (I don’t know why you would but you could.)

As always, fixes and enhancements welcome.