Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<pre> elements - problematic characters and auto replacement #34545

Open
hamishwillee opened this issue Jul 1, 2024 · 0 comments
Open

<pre> elements - problematic characters and auto replacement #34545

hamishwillee opened this issue Jul 1, 2024 · 0 comments
Labels
Content:HTML Hypertext Markup Language docs

Comments

@hamishwillee
Copy link
Collaborator

MDN URL

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre

What specific section or headline is this issue about?

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre#escaping_reserved_characters

What information was incorrect, unhelpful, or incomplete?

  1. The terminology is imprecise. It refers to reserved characters, where in fact HTML refers to things that aren't allowed in particular contexts. For example you can happily use a < as long as you don't use it in a way that a browser might interpret as a tag. Similarly " chars are allowed in many places, but not inside tag attributes that are defined using them. We should talk about problematic characters and explain this a bit better.
  2. Some characters are allowed in any context according to the spec, such as & but can be misused - for example if used as the start of a character reference, the reference should be valid. Also, anecdotally some browsers complain if & is used in pre and isn't followed by a character reference (that looks to be off-spec).
  3. The doc is focused on the use of <pre> to get layout you want, which is reasonable. But it doesn't cover the fact that the element can contain tags and have other formatting. A main use is not just layout of pretty images, but probably generating layout to syntax-highlight code - and that requires some use of tags etc.
  4. The section on Escaping reserved characters needs a little more nuance. Firstly to capture contexts when they are are not allows. Also, from Too many clicks to obtain HTML char entity names #34383 (comment) to capture some concerns about automatic replacement of reserved characters. At high level this is again to note that what is reserved character depends on context, secondly that if you are going to do any form of replacement then & has to be done first so that any "already replaced characters" are not double-replaced, and lastly note that because of all what needs to be escaped depends on context, generally a manual update is safer.

What did you expect to see?

More nuance. Terminology to change from "reserved" to "problematic", or "special" characters.

Do you have any supporting links, references, or citations?

This came from a discussion in #34383

Do you have anything more you want to share?

No response

@hamishwillee hamishwillee added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jul 1, 2024
@github-actions github-actions bot added the Content:HTML Hypertext Markup Language docs label Jul 1, 2024
@Josh-Cena Josh-Cena removed the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:HTML Hypertext Markup Language docs
Projects
None yet
Development

No branches or pull requests

2 participants