You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Correct outcome should be (not considering implied HTML):
body > p
I assume it must have been discussed in the past but couldn't find any trace of prior issue.
Yes, not using optional closing tags is generally considered bad coding practice (not considering "google output compression"), and I assume that fixing this would not be a trivial task (considering complexity of specs), but current state when VSCode Outline lies about resulting HTML structure is not fortunate.
(I'm not sure about support for implied elements and their corresponding tags, but I assume it might be confusing to some seeing e.g. tbody nodes inside table that has not explicit opening tbody tag authored in the source code. But it would probably not spoil anything to see it there, since it would better reflect the reality. Different issue, perhaps?)
More verbose descriptive article
<html>
<!--
This tag does not have to be present in the source code: <html> tag (without attributes) is implied
-->
<head><!-- Ditto <head>. -->
<title>Optional closing tags test for VS Code</title>
<!-- <title> is the only mandatory tag in HTML document -->
<body>
<!--
Neither <body> is mandatory.
Presence of <body> here automatically finished <head>.
In fact occurrence of any element that is not allowed in HEAD would do the same.
-->
<p>HTML syntax tree in current Visual Studio Code is not correct.
<h2>Trivia:</h2>
<p>There are several block level elements with optional closing tags in HTML:
<dl>
<dt><code>P</code>
<dd>paragraph cannot contain block-level elements so any of them finishes it,
<dt><code>HTML</code>, <code>HEAD</code>, <code>BODY</code> <code>TBODY</code> <code>COLGROUP</code>
<dd>those are even <i>implied</i>, so even their starting tags are optional; presence of elements that belongs there creates them
<dt><code>LI</code>, <code>DT</code>, <code>DD</code>
<dd>finished by parent <code>/UL</code>, <code>/OL</code>, <code>/DL</code> or following <code>LI</code>, <code>DT</code>, <code>DD</code>
</dl>
<p>If you place cursor in the end of the source of definition list above, you'll observe
<code>html > head > body > p > p > dl > dt > dd > dt > dd > dt > dd</code> being displayed in breadcrumbs, what implies that given definition is nested in of preceding definitions what in two nested paragraphs which are children of body <i>in</i> head.
<p>It is completely different of how HTML5 conforming agent interprets it. Correct path should be <code>html > body > dl > dd</code>
<p>This affects Breacrubs and logicaly Outline and to some degree Format document action. (IIRC formatting is currently done in other library than language service, but mentioning it for completeness).
<!-- end of file finishes all opened tags -->
The text was updated successfully, but these errors were encountered:
Smart indentation also misunderstands optional closing tags (nests too deep) and while working in this style the automatic insertion of the closing tag is annoying. There are very few occasions where an optional closing tag is actually needed as in nearly all practical situations a closing tag is implied at the correct position for all elements where the HTML5 specification allows optional tags.
myfonj
changed the title
Support for optional closing tags (e.g. paragraphs and list items) in Breadcrumbs, Outline and formatters
Support for optional (implicit) closing tags (e.g. paragraphs and list items) in Breadcrumbs, Outline and formatters
Sep 16, 2024
For HTML document
Placing cursor at the end of the "c" paragraph makes Breadcrumbs display
It is incorrect per the HTML spec and in effect differs from from what happens in real HTML parsers. (It is still valid, though.)
Correct outcome should be (not considering implied
HTML
):I assume it must have been discussed in the past but couldn't find any trace of prior issue.
Yes, not using optional closing tags is generally considered bad coding practice (not considering "google output compression"), and I assume that fixing this would not be a trivial task (considering complexity of specs), but current state when VSCode Outline lies about resulting HTML structure is not fortunate.
(I'm not sure about support for implied elements and their corresponding tags, but I assume it might be confusing to some seeing e.g.
tbody
nodes insidetable
that has not explicit openingtbody
tag authored in the source code. But it would probably not spoil anything to see it there, since it would better reflect the reality. Different issue, perhaps?)More verbose descriptive article
The text was updated successfully, but these errors were encountered: