8
$\begingroup$

Scenario (true story): after posting something I became doubtful about certain claim there, so I want to hide it until I clarify my doubts.

Of course I could just move that part to a temporary file, but it would be much more convenient to have it in place, ready for further processing. Presently I have put it in <del>...</del> but this is not quite what I want, since it creates impression that this part is definitely wrong, while actually I simply don't know yet whether it is or not.

Is there a way?

$\endgroup$
15
$\begingroup$

You can hide the part in HTML comments:

BEFORE <!-- this is something I want to hide --> AFTER

produces:

BEFORE AFTER


Spoilers would be another option, but perhaps less clear in conveying the intention.

>! This is something I want to hide

produces

This is something I want to hide

$\endgroup$
13
$\begingroup$

Since other answers mention HTML comments, let me clarify that using them is only a commonly employed custom on SE sites, which just abuses the fact that it works by accident.

In reality, the Stackexchange Markdown parser does not support HTML comments. What actually happens is that the initial < followed by unrecognized content is parsed as an invalid HTML tag, which makes the parser strip everything up to the next > character. See e.g. https://meta.stackexchange.com/a/120418.

One consequence is that these “comments” don’t obey the syntactic rules governing actual HTML comments: for example, a “comment” such as <!-- asdf <br> qwer --> stops early at the first >, and the qwer --> part is visible in the output: qwer -->.

Another consequence is that there is nothing special about <!--: you can use any other invalid (or unsupported) HTML tag for the same purpose, for example <this is my comment: fk dsajk fdsjka hfjdks fhjkhadsa>:

$\endgroup$
2
7
$\begingroup$

Since Stack Exchange allows also some limited use of html, you can use <!---...---> to make a "comment" inside the post. Check the source code of this answer for an example.

I will add that I have seen warnings that mixing MarkDown and HTML too much might sometimes lead to problems, I do not know much about types of are known for html comments.

EDIT: If I understood correctly the information from the link provided in Emil Jeřábek's comment, HTML comments aren't officially supported. So one probably should not rely on the fact that they will always work. (On the other hand, if they are used just a temporary workaround, maybe that isn't that terrible.) See also: What HTML tags are allowed on Stack Exchange sites?

EDIT2: In the meantime, Emil Jeřábek added an answer where he explains this in detail.


This post mentions problems with > inside the comment: > is closing HTML comments without a -​- delimiter. The same issue is mentioned here: Can't Seem to comment out a link. (And in both cases it is mentioned that it is and not a bug.)

Let us try some test concerning this.

You can see that the following input does not hide everything:

We'll try both $a<b$ and $a>b$ (with and without dollars):  
<!-- a<b -->  
<!-- a>b --> 
<!-- $a<b$ -->   
<!-- $a>b$ -->  
<!-- Link to [this question](https://meta.mathoverflow.net/q/4781) -->  

We'll try both $a<b$ and $a>b$ (with and without dollars):

b -->
$\endgroup$
5
  • $\begingroup$ Thank you! @Glorfindel was one minute quicker, and also provided another option, so... $\endgroup$ Dec 15 '20 at 14:06
  • 1
    $\begingroup$ Yes, Stack Exchange allows some limited use of html, but comments are not part of the allowed use. See meta.stackexchange.com/a/120418. $\endgroup$ Dec 16 '20 at 9:40
  • $\begingroup$ @EmilJeřábek Just to clarify what your comment (and animuson's answer you oinked) is saying - the gist of it that using HTML comments is not officially supported. (And the fact that they actually work - at least in the examples posted in the answeres here - should be considered a lucky accident, byt is not by any means guaranteed.) Is that more-or-less correct? $\endgroup$ Dec 16 '20 at 10:07
  • $\begingroup$ I will add that I was trying to find some kind of official documentation about this when I was writing the answer. And I saw that HTML comments are not mentioned here: What HTML tags are allowed on Stack Exchange sites? However, since I saw them used on the site several times, I thought that it might be just an oversight that they are missing in that list. $\endgroup$ Dec 16 '20 at 10:09
  • 1
    $\begingroup$ Yes, HTML comments sort-of work by accident: the parser removes them not because they are comments, but because it considers them invalid HTML tags, which also means they behave syntactically in a different way than proper HTML comments. See my answer below. $\endgroup$ Dec 16 '20 at 10:33
3
$\begingroup$

$$

% You can hide your drafts inside the math environment, using the percentage symbol. Click edit on my answer to see it in action.

$$

$$ % Assume the Riemann Hypothesis is false. % Then clearly... hmm. $$

$\endgroup$
2
1
$\begingroup$

"posting something"... Do you mean a question or an answer? I occasionally to the following with my answers.
"Delete" it, until I am ready, then "undelete" it.
I have never tried this on my questions, but someone once told me that I cannot do that with questions.

$\endgroup$
3
  • $\begingroup$ The part I want to hide in this particular case is only a small portion of the post, the rest is perfectly sane. And I believe this can happen equally with questions and with answers. $\endgroup$ Dec 15 '20 at 14:35
  • 2
    $\begingroup$ Concerning the fact that it is not possible to edit self-deleted questions, I was given this link as a place where it is (in some way) documented: Couple of issues with Roomba Turbocharging. And I can confirm that when I tried it myself - I was able to edit self-deleted answers, but not self-deleted questions. (This restriction does not apply to questions which were deleted by other users, not the OP.) $\endgroup$ Dec 15 '20 at 14:45
  • 2
    $\begingroup$ In connection to this, it is worth adding that editing a deleted answer bumps the question - which might be not desired. (This related feature request was marked as status-by-design: Stop an edited deleted answer from bumping the question.) Of course, this is moot if both the question and the answer are deleted. $\endgroup$ Dec 15 '20 at 14:48

You must log in to answer this question.

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