-
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
Add <code> element inside applicable <pre> elements #3768
Conversation
In wattsi and the html-build sources, the code related to syntax highlighting is agnostic toward whether or not there’s a So there’s nothing special about those In other words, there are no build adjustments to be made on our side for this. But whether the external highlighter script that we call needs to be adjusted to do something different because of those elements, I dunno. |
Wow, thanks @Zirro! @sideshowbarker, it seems like Zirro moved the class="lang" from the In that case, we'd need to adjust wattsi, right? Hmm. |
Nope, my highlighter is fine, it doesn't care one bit whether there's a You'll just need to change wattsi to look for the class on the |
That seems unnecessary and I strongly prefer this not be landed that way
I suggest we not follow that suggestion :) And further I think we should consider also changing the spec to not suggest that, because it’s not objectively a better way to do the markup by any measure
Right
Yeah, we’d need to adjust the wattsi code, and it’d be significantly more trouble to adjust it to look for a The cost of doing that would still be worthwhile if there were a compelling benefit. But it doesn’t seem like there is any benefit compelling enough to merit the cost |
Makes sense. @Zirro, any objections to moving the class to the I guess one reason the spec might suggest this is that you could then use the same highlighter code for inline code samples, not just big pre blocks. |
bfccca1
to
91eea3a
Compare
@domenic That's fine with me. Done, and rebased on latest master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t support adding code
children to all the pre
elements. It’s not necessary and in fact we have some evidence that it may actually measurably more harmful than not using code
children in pre
.
See @tabatkins comment at #2751 (comment), where he indicates that the CSS specs are very intentionally not using code
children in their pre
blocks because:
Probably for the same reason we just use
pre
in the CSS specs -<pre><code>
makes the magical-newline-omitting ofpre
work even worse thanpre
by itself.
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 code
children as the first child of every single pre
element that has an example of JavaScript or HTML or CSS or whatever in it.
I’ll create a PR with a patch for that.
Yeah — that’s a great change. I really think we need that. Lacking that at this point, I’ve needed to make the syntax-highlighter code assume that any |
I guess we should wait to merge this until the discussion in #3772 gets a bit further. In the meantime, let me put the commit message I drafted here for safe keeping:
|
Upon further consideration I’m dropping my objection to this change, and I have a patch ready to land that aligns with this PR, by adding support to Wattsi for sending So @Zirro are you still able to roll back this branch to the original state of the patch at the time when you initially raised the PR? If so, then I think that would be the better way to land this. I mean specifically, with the |
91eea3a
to
7250f9a
Compare
Okay, I've moved the classes back over to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There’s an pre
element at line 734 of the source on this branch, with id=intro-early-example
. It contains an HTML markup example but <code class="html">…</code>
hasn’t been added around its contents. Is that intentional?
Thanks for catching that. It looks like I missed |
Cool. I think it may affect a few more than just those. Search for And search for |
396eebf
to
11c0989
Compare
The main purpose of this commit is to adapt to the new markup style in whatwg/html#3768. This also fixes minor inconsistencies and redundancies noted throughout the stylesheet for pre elements.
The main purpose of this commit is to adapt to the new markup style in whatwg/html#3768. This also fixes minor inconsistencies and redundancies noted throughout the stylesheet for pre elements. And it removes special treatment of the "asn" class, which does not appear in any current specs.
The main purpose of this commit is to adapt to the new markup style in whatwg/html#3768. This also fixes minor inconsistencies and redundancies noted throughout the stylesheet for pre elements. (Most notably, it will treat Bikeshed-produced IDL and CSS blocks the same as those in HTML.) And it removes special treatment of the "asn" class, which does not appear in any current specs.
0ecdf97
to
11acde7
Compare
Reviewed here and approved — and also approved the whatwg/whatwg.org PRs. So I think we’re finally ready to merge all this. |
So I meant to say in my previous comment that the Travis CI check is now green because I figured out and fixed the problem. The cause was 100% my flub… I introduced a regression in wattsi’s behavior in whatwg/wattsi@b7d18be#diff-1922eb90770bdd34ac96cc9db339faebL1927.
I was wrong about that. That had it hardcoded to call a function to conditionally write the doctype — but the assumption I wrote that with didn’t hold up for the case when writing the index-html files with syntax highlighting not enabled. So in whatwg/wattsi@f3e6a62 I fixed (unregressed) it to (once again) unconditionally emit the doctype when writing HTML files. |
This change adds https://github.com/tabatkins/highlighter as a submodule and updates the build script to use the highlight server when running wattsi, as documented at tabatkins/highlighter#6 (comment) Relies on whatwg/wattsi#63 Addresses #113 Relates to whatwg/html#3768 and whatwg/whatwg.org#215
The main purpose of this commit is to adapt to the new markup style in whatwg/html#3768. This also fixes minor inconsistencies and redundancies noted throughout the stylesheet for pre elements. (Most notably, it will treat Bikeshed-produced IDL and CSS blocks the same as those in HTML.) And it removes special treatment of the "asn" class, which does not appear in any current specs.
This change adds https://github.com/tabatkins/highlighter as a submodule and updates the build script to use the highlight server when running wattsi, as documented at tabatkins/highlighter#6 (comment) This change reverts the revert made in ffe6f19. It fixes the problem which made that revert necessary; the fix is to make the PYTHONPATH in the local environment include the path to the Pygments copy in the highlighter submodule. Fixes #169 Relies on whatwg/wattsi#63 Addresses #113 Relates to whatwg/html#3768 and whatwg/whatwg.org#215
This change adds https://github.com/tabatkins/highlighter as a submodule and updates the build script to use the highlight server when running wattsi, as documented at tabatkins/highlighter#6 (comment) This change reverts the revert made in ffe6f19. It fixes the problem which made that revert necessary; the fix is to make the PYTHONPATH in the local environment include the path to the Pygments copy in the highlighter submodule. Fixes #169 Relies on whatwg/wattsi#63 Addresses #113 Relates to whatwg/html#3768 and whatwg/whatwg.org#215
This change adds https://github.com/tabatkins/highlighter as a submodule and updates the build script to use the highlight server when running wattsi, as documented at tabatkins/highlighter#6 (comment) This change reverts the revert made in ffe6f19. It fixes the problem which made that revert necessary; the fix is to make the PYTHONPATH in the local environment include the path to the Pygments copy in the highlighter submodule. Fixes #169 Relies on whatwg/wattsi#63 Addresses #113 Relates to whatwg/html#3768 and whatwg/whatwg.org#215
This change adds https://github.com/tabatkins/highlighter as a submodule and updates the build script to use the highlight server when running wattsi, as documented at tabatkins/highlighter#6 (comment) This change reverts the revert made in ffe6f19. It fixes the problem which made that revert necessary; the fix is to make the PYTHONPATH in the local environment include the path to the Pygments copy in the highlighter submodule. Fixes #169. Relies on whatwg/wattsi#63. Addresses #113. Relates to whatwg/html#3768 and whatwg/whatwg.org#215.
This change adds https://github.com/tabatkins/highlighter as a submodule and updates the build script to use the highlight server when running wattsi, as documented at tabatkins/highlighter#6 (comment) This change reverts the revert made in ffe6f19. It fixes the problem which made that revert necessary; the fix is to make the PYTHONPATH in the local environment include the path to the Pygments copy in the highlighter submodule. Fixes #169. Relies on whatwg/wattsi#63. Addresses #113. Relates to whatwg/html#3768 and whatwg/whatwg.org#215.
The existing wattsi code for causing IDL blocks to be omitted from the dev edition quit working when whatwg/html#3768 moved class=idl attributes off `pre` elements and instead onto to `code` children of those elements, So the first part of this change causes those `code class=idl` elements to be dropped as expected. But as a result of that, the now-empty `pre` element parents of those `code` elements are left behind. So the second part of this change looks for those empty `pre` elements and drops them. Fixes #84
This change drops the `data-x=""` attribute+value that was included in all `code` elements added in #3768 (a6e5462). whatwg/wattsi#86 makes it unnecessary to to use `data-x=""` for `code` elements that are children of `pre` elements.
This change drops the `data-x=""` attribute+value that was included in all `code` elements added in #3768 (a6e5462). whatwg/wattsi#86 makes it unnecessary to to use `data-x=""` for `code` elements that are children of `pre` elements.
This change drops the `data-x=""` attribute+value that was included in all `code` elements added in #3768 (a6e5462). whatwg/wattsi#86 makes it unnecessary to use `data-x=""` for `code` elements that are children of `pre` elements.
The existing wattsi code for causing IDL blocks to be omitted from the dev edition quit working when whatwg/html#3768 moved class=idl attributes off `pre` elements and instead onto to `code` children of those elements. So the first part of this change causes those `code class=idl` elements to be dropped as expected. But as a result of that, the now-empty `pre` element parents of those `code` elements are left behind. So the second part of this change looks for those empty `pre` elements and drops them. Fixes #84.
The existing wattsi code for causing IDL blocks to be omitted from the dev edition quit working when whatwg/html#3768 moved class=idl attributes off `pre` elements and instead onto to `code` children of those elements, So the first part of this change causes those `code class=idl` elements to be dropped as expected. But as a result of that, the now-empty `pre` element parents of those `code` elements are left behind. So the second part of this change looks for those empty `pre` elements and drops them. This change reverts the e1e3599 revert that was made because — as initially implemented in c13e47b — stray `</pre>` end tags got left behind for all `pre` elements that were omitted. This change corrects that problem (it ensures the end tags get removed as expected). Fixes #84
The existing wattsi code for causing IDL blocks to be omitted from the dev edition quit working when whatwg/html#3768 moved class=idl attributes off `pre` elements and instead onto to `code` children of those elements, So the first part of this change causes those `code class=idl` elements to be dropped as expected. But as a result of that, the now-empty `pre` element parents of those `code` elements are left behind. So the second part of this change looks for those empty `pre` elements and drops them. This change reverts the e1e3599 revert that was made because — as initially implemented in c13e47b — stray `</pre>` end tags got left behind for all `pre` elements that were omitted. This change corrects that problem (it ensures the end tags get removed as expected). Fixes #84
The existing wattsi code for causing IDL blocks to be omitted from the dev edition quit working when whatwg/html#3768 moved class=idl attributes off `pre` elements and instead onto to `code` children of those elements, So the first part of this change causes those `code class=idl` elements to be dropped as expected. But as a result of that, the now-empty `pre` element parents of those `code` elements are left behind. So the second part of this change looks for those empty `pre` elements and drops them. This change reverts the e1e3599 revert that was made because — as initially implemented in c13e47b — stray `</pre>` end tags got left behind for all `pre` elements that were omitted. This change corrects that problem (it ensures the end tags get removed as expected). Fixes #84
The existing wattsi code for causing IDL blocks to be omitted from the dev edition quit working when whatwg/html#3768 moved class=idl attributes off `pre` elements and instead onto to `code` children of those elements, So the first part of this change causes those `code class=idl` elements to be dropped as expected. But as a result of that, the now-empty `pre` element parents of those `code` elements are left behind. So the second part of this change looks for those empty `pre` elements and drops them. This change reverts the e1e3599 revert that was made because — as initially implemented in c13e47b — stray `</pre>` end tags got left behind for all `pre` elements that were omitted. This change corrects that problem (it ensures the end tags get removed as expected). Fixes #84.
This change drops the `data-x=""` attribute+value that was included in all `code` elements added in #3768 (a6e5462). whatwg/wattsi#86 makes it unnecessary to use `data-x=""` for `code` elements that are children of `pre` elements.
This change drops the `data-x=""` attribute+value that was included in all `code` elements added in #3768 (a6e5462). whatwg/wattsi#86 makes it unnecessary to use `data-x=""` for `code` elements that are children of `pre` elements.
Resolves #3753 and #3764.
This is not ready to be merged yet as it'll also require a few changes to the build system and CSS to target
<code>
elements rather than<pre>
elements. I'd also like to go over it again to make sure it's correct in all locations.I added an explicit
html
class rather than having it be implicit as was the case before, since there are some non-HTML/CSS/JS/IDL<pre>
s as well. Figured it might come in handy some day.@sideshowbarker, would these changes work well for you once the syntax highlighting has been adjusted to account for the
<code>
elements?/browsers.html ( diff )
/browsing-the-web.html ( diff )
/canvas.html ( diff )
/common-dom-interfaces.html ( diff )
/common-microsyntaxes.html ( diff )
/comms.html ( diff )
/custom-elements.html ( diff )
/dnd.html ( diff )
/dom.html ( diff )
/edits.html ( diff )
/embedded-content-other.html ( diff )
/embedded-content.html ( diff )
/form-control-infrastructure.html ( diff )
/form-elements.html ( diff )
/forms.html ( diff )
/grouping-content.html ( diff )
/history.html ( diff )
/iframe-embed-object.html ( diff )
/image-maps.html ( diff )
/imagebitmap-and-animations.html ( diff )
/images.html ( diff )
/input.html ( diff )
/interaction.html ( diff )
/interactive-elements.html ( diff )
/introduction.html ( diff )
/links.html ( diff )
/media.html ( diff )
/microdata.html ( diff )
/obsolete.html ( diff )
/offline.html ( diff )
/parsing.html ( diff )
/rendering.html ( diff )
/scripting.html ( diff )
/sections.html ( diff )
/semantics-other.html ( diff )
/semantics.html ( diff )
/server-sent-events.html ( diff )
/structured-data.html ( diff )
/syntax.html ( diff )
/system-state.html ( diff )
/tables.html ( diff )
/text-level-semantics.html ( diff )
/timers-and-user-prompts.html ( diff )
/web-messaging.html ( diff )
/web-sockets.html ( diff )
/webappapis.html ( diff )
/webstorage.html ( diff )
/window-object.html ( diff )
/workers.html ( diff )