18

I think that before a user posts a question or answer, the system should warn if the post contains non-HTML tags (and disallowed HTML tags) that may be invisible when displayed. For example, I edited this question because it looked like something was missing:

The error is in . 

As it turned out, it had a hidden tag that clarified the meaning somewhat:

The error is in <ImageView>. 

This went unnoticed for over a year before I edited it. I hope a warning like this will help reduce the number of post issues like this, since the warning will alert the user, say, that the unescaped tag should be wrapped like this.

6
  • Isn't it just as big of a problem if the OP is trying to talk about HTML and it's not going to display correctly?
    – Wooble
    Commented Mar 8, 2013 at 16:34
  • Seems like the rare case where they didn't use backticks or <code>. Usually users abuse those features...
    – user7116
    Commented Mar 8, 2013 at 16:34
  • 3
    Happens quite often with generic types in C#. Commented Mar 8, 2013 at 16:44
  • @CodesInChaos truth. An easy first pass at this feature would be to check the post for the text Enumerable< not contained in code formatting...
    – AakashM
    Commented Mar 8, 2013 at 16:57
  • happens a lot with people trying to post XML data, not knowing it should go in a code block Commented Mar 8, 2013 at 18:01
  • @AakashM That doesn't account for every other type of generic type, including user-defined ones. Better to look for matched < and > with a maximum length
    – Basic
    Commented Mar 8, 2013 at 21:00

2 Answers 2

8

Merely non-HTML tags wouldn't suffice. If this was implemented it should be any tags that aren't allowed in posts like <form> and <div>. I see people do this all the time:

I want the to change depending on the value.

Source:

I want the <select> to change depending on the <input> value.

I habitually check the post source by clicking [edit] whenever I see an awkward sentence like that.

One side of me wants to disagree with this request, since it should be pretty obvious there's a mistake if you actually preview your post before hitting submit, which you should, always. I'm not sure if this would encourage laziness.

On the other hand, I see a lot of posts about HTML get downvoted along with "Code? What code?" comments because the code is totally hidden. The burden is on the poster really, but maybe a warning would be a good thing for overall quality and would help newer users get used to formatting correctly.

Possible alternative solution: Would it make more sense just to output the brackets on disallowed tags as entities, so that they appear? For instance if I typed <input> without formatting it as code, it would appear as <input>. It would still be unformatted, but better than being invisible. Is there any point in hiding disallowed tags in the first place?

1
  • +1 for the alternative - if it's not a recognised token, escape html entities.
    – Basic
    Commented Mar 8, 2013 at 21:01
0

Whenever you reject some content that looks like a tag, output it with encoded entities in red. Something like <span class="invalid-html">&lt;div&gt;</span>.

1
  • I like the idea but I suspect people would use this as a different way of formatting their posts/highlighting things.
    – Basic
    Commented Mar 8, 2013 at 21:03

You must log in to answer this question.

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