-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Use <code> element inside the <pre> elements with code examples #3764
Comments
So I made comments about this at #3768 (review). I don’t support adding See @tabatkins comment at #2751 (comment), where he indicates that the CSS specs are very intentionally not using
So I think the change we instead should be making here is to update the suggestions and examples in the spec to align with what most authors actually seem to be doing (and what the CSS specs are doing) — that is, to not suggest using I’ll create a PR with a patch for that. |
What does that actually mean? Can someone please provide examples? |
This changes updates some examples of <pre> elements to not use <code> children, and also updates some related non-normative guidance in the spec to advise that when marking up <pre> elements that contain content written in particular programming language, a class attribute+value on the <pre> element itself can be used to indicate the particular programming language — without the need to always instead add a <code> child with a class attribute+value. Relates to #3764
See #3772 |
This change updates some examples of <pre> elements to not use <code> children, and also updates some related non-normative guidance in the spec to advise that when marking up <pre> elements that contain content written in a particular programming language, a class attribute+value on the <pre> element itself can be used to indicate the language — without the need to always instead add a <code> child with a class attribute+value. Relates to #3764
This change updates some examples of <pre> elements to not use <code> children, and also updates some related non-normative guidance in the spec to advise that when marking up <pre> elements that contain content written in a particular programming language, a class attribute+value on the <pre> element itself can be used to indicate the language — without the need to always instead add a <code> child with a class attribute+value. Relates to #3764
This change updates some examples of <pre> elements to not use <code> children, and also updates some related non-normative guidance in the spec to advise that when marking up <pre> elements that contain content written in a particular programming language, a class attribute+value on the <pre> element itself can be used to indicate the language — without the need to always instead add a <code> child with a class attribute. Relates to #3764
This change updates some examples of <pre> elements to not use <code> children, and also updates some related non-normative guidance in the spec to advise that when marking up <pre> elements that contain content written in a particular programming language, a class attribute+value on the <pre> element itself can be used to indicate the language — without the need to always instead add a <code> child with a class attribute. Relates to #3764
This change updates some examples of <pre> elements to not use <code> children, and also updates some related non-normative guidance in the spec to advise that when marking up <pre> elements that contain content written in a particular programming language, a class attribute+value on the <pre> element itself can be used to indicate the language — without the need to always instead add a <code> child with a class attribute. Relates to #3764
OK, upon further consideration I’m dropping my objection to this, and I have a patch ready to land that aligns with this, by adding support to Wattsi for sending |
See test at http://software.hixie.ch/utilities/js/live-dom-viewer/saved/6008. A plain |
Thank you @tabatkins! The behaviour of leading and trailing newlines is inconsistent indeed. Trying to make it more consistent would affect too many legacy sites I suppose? – especially as this is not specific to I don’t think this is a big enough reason to not recommend using |
Thanks for providing these details @tabatkins! That is rather interesting. I suppose this behaviour is defined implicitly somewhere in the HTML parser spec?
If it remains true that it only affects newlines at the beginning or end of the text in the situations where it happens at all, I'm happy to report that this shouldn't be a significant issue in this case. Out of the 1027 code samples with When I next have time to update the pull request - hopefully later this week, I will remove these and verify that the rendering still looks as intended. |
Fixes whatwg#3753 (for JS) and also marks up the HTML examples with their own class. Fixes whatwg#3764. This will help with ongoing work to syntax-highlight all code in the spec; see whatwg#3753.
For semantic purposes, the specification suggests that
code
elements be used insidepre
elements which contain code. This is currently not the case for the code examples presented throughout the specification.The text was updated successfully, but these errors were encountered: