[html5] r8001 - [cgiow] (3) Change the HTML parser from using 'act as if' tokens to inlining the [...]

whatwg at whatwg.org whatwg at whatwg.org
Mon Jul 1 14:19:50 PDT 2013


Author: ianh
Date: 2013-07-01 14:19:49 -0700 (Mon, 01 Jul 2013)
New Revision: 8001

Modified:
   complete.html
   index
   source
Log:
[cgiow] (3) Change the HTML parser from using 'act as if' tokens to inlining the behaviour. The only normative changes should be the number of 'parse errors' detected in certain edge cases. Three occurrences of 'act as if' remain. This should make it a lot easier to fix the spec's namespace issues.
Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=22322
Affected topics: HTML Syntax and Parsing

Modified: complete.html
===================================================================
--- complete.html	2013-06-28 22:44:17 UTC (rev 8000)
+++ complete.html	2013-07-01 21:19:49 UTC (rev 8001)
@@ -256,7 +256,7 @@
 
   <header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
    <hgroup><h1 class=allcaps>HTML</h1>
-    <h2 class="no-num no-toc">Living Standard — Last Updated 28 June 2013</h2>
+    <h2 class="no-num no-toc">Living Standard — Last Updated 1 July 2013</h2>
    </hgroup><dl><dt><strong>Web developer edition:</strong></dt>
     <dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
     <dt>Multiple-page version:</dt>
@@ -89584,8 +89584,7 @@
    <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
    <dd>
 
-    <p>Act as if a start tag token with the tag name "head" and no
-    attributes had been seen, then reprocess the current token.</p>
+    <p>Act s described in the "anything else" entry below.</p>
 
    </dd>
 
@@ -89599,10 +89598,19 @@
    <dt>Anything else</dt>
    <dd>
 
-    <p>Act as if a start tag token with the tag name "head" and no
-    attributes had been seen, then reprocess the current
-    token.</p>
+    <!-- fake <head> -->
 
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "head" start tag token with no attributes.</p>
+
+    <p>Set the <a href=#head-element-pointer><code title="">head</code> element pointer</a>
+    to the newly created <code><a href=#the-head-element>head</a></code> element.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>".</p>
+
+    <!-- end of fake <head> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
   </dl><h6 id=parsing-main-inhead><span class=secno>12.2.5.4.4 </span>The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h6>
@@ -89796,8 +89804,7 @@
      <li><p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
      insertion modes</a>.</p>
 
-     <li><p><a href=#reset-the-insertion-mode-appropriately title="reset the insertion mode appropriately">Reset the
-     parser's insertion mode appropriately</a>.</li>
+     <li><p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</li>
 
     </ol></dd>
 
@@ -89812,9 +89819,16 @@
 
     <!-- can't get here with an EOF and a fragment case -->
 
-    <p>Act as if an end tag token with the tag name "head" had
-    been seen, and reprocess the current token.</p>
+    <!-- start of fake </head> -->
+    <p>Pop the <a href=#current-node>current node</a> (which will be the
+    <code><a href=#the-head-element>head</a></code> element) off the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
 
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</a>".</p>
+    <!-- end of fake </head> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
   </dl><h6 id=parsing-main-inheadnoscript><span class=secno>12.2.5.4.5 </span>The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h6>
@@ -89871,10 +89885,19 @@
 
     <!-- can't get here with an EOF and a fragment case -->
 
-    <p><a href=#parse-error>Parse error</a>. Act as if an end tag with the tag
-    name "noscript" had been seen and reprocess the current
-    token.</p>
+    <p><a href=#parse-error>Parse error</a>.</p>
 
+    <!-- fake </noscript> -->
+    <p>Pop the <a href=#current-node>current node</a> (which will be a
+    <code><a href=#the-noscript-element>noscript</a></code> element) from the <a href=#stack-of-open-elements>stack of open
+    elements</a>; the new <a href=#current-node>current node</a> will be a
+    <code><a href=#the-head-element>head</a></code> element.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>".</p>
+    <!-- end fake </noscript> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
   </dl><h6 id=the-after-head-insertion-mode><span class=secno>12.2.5.4.6 </span>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h6>
@@ -89958,10 +89981,15 @@
 
    <dt>Anything else</dt>
    <dd>
-    <p>Act as if a start tag token with the tag name "body" and no
-    attributes had been seen, then set the <a href=#frameset-ok-flag>frameset-ok
-    flag</a> back to "ok", and then reprocess the current
-    token.</p>
+
+    <!-- fake <body>, but without resetting frameset-ok -->
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "body" start tag token with no attributes.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>".</p>
+    <!-- end fake <body> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
   </dl><h6 id=parsing-main-inbody><span class=secno>12.2.5.4.7 </span>The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h6>
@@ -90145,10 +90173,37 @@
    <dt>An end tag whose tag name is "html"</dt>
    <dd>
 
-    <p>Act as if an end tag with tag name "body" had been seen,
-    then, if that token wasn't ignored, reprocess the current
+    <!-- fake </body> -->
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-scope title="has an element in scope">have a <code>body</code> element
+    in scope</a>, this is a <a href=#parse-error>parse error</a>; ignore the
     token.</p>
 
+    <!-- if we get here, the insertion mode here is forcibly "in
+    body". -->
+
+    <p>Otherwise, if there is a node in the <a href=#stack-of-open-elements>stack of open
+    elements</a> that is not either a <code><a href=#the-dd-element>dd</a></code> element, a
+    <code><a href=#the-dt-element>dt</a></code> element, an <code><a href=#the-li-element>li</a></code> element, an
+    <code><a href=#the-optgroup-element>optgroup</a></code> element, an <code><a href=#the-option-element>option</a></code> element, a
+    <code><a href=#the-p-element>p</a></code> element, an <code><a href=#the-rp-element>rp</a></code> element, an
+    <code><a href=#the-rt-element>rt</a></code> element, a <code><a href=#the-tbody-element>tbody</a></code> element, a
+    <code><a href=#the-td-element>td</a></code> element, a <code><a href=#the-tfoot-element>tfoot</a></code> element, a
+    <code><a href=#the-th-element>th</a></code> element, a <code><a href=#the-thead-element>thead</a></code> element, a
+    <code><a href=#the-tr-element>tr</a></code> element, the <code><a href=#the-body-element>body</a></code> element, or the
+    <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
+    error</a>.</p> <!-- (some of those are fragment cases, e.g. for
+    <tbody> you'd have hit the first paragraph since the <body>
+    wouldn't be in scope, unless it was a fragment case) -->
+
+    <!-- If we ever change the frameset-ok flag to an insertion mode,
+    then we'd have to somehow keep track of its state when we switch
+    to after-body. -->
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-afterbody title="insertion mode: after body">after body</a>".</p>
+    <!-- end fake </body> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <!-- start tags for non-phrasing flow content elements -->
@@ -90167,8 +90222,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an
     element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name "p" had
-    been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
 
@@ -90181,8 +90235,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p>If the <a href=#current-node>current node</a> is an element whose tag name
     is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
@@ -90200,8 +90253,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
 
@@ -90229,8 +90281,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token, and set the
     <a href=#form-element-pointer><code title=form>form</code> element pointer</a> to
@@ -90249,13 +90300,27 @@
      <li><p>Initialize <var title="">node</var> to be the <a href=#current-node>current
      node</a> (the bottommost node of the stack).</li>
 
-     <li><p><i>Loop</i>: If <var title="">node</var> is an
-     <code><a href=#the-li-element>li</a></code> element, then act as if an end tag with the tag
-     name "li" had been seen, then jump to the last step.</li>
+     <li>
 
+      <p><i>Loop</i>: If <var title="">node</var> is an <code><a href=#the-li-element>li</a></code> element, then run these
+      substeps:</p>
+
+      <ol><!-- fake </li> --><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except for <code><a href=#the-li-element>li</a></code> elements.</li>
+
+       <li><p>If the <a href=#current-node>current node</a> is not an <code><a href=#the-li-element>li</a></code> element, then this is a
+       <a href=#parse-error>parse error</a>.</li>
+
+       <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until an <code><a href=#the-li-element>li</a></code>
+       element has been popped from the stack.</li>
+       <!-- end of fake </li> -->
+
+       <li><p>Jump to the step labeled <i>done</i> below.</li>
+
+      </ol></li>
+
      <li><p>If <var title="">node</var> is in the <a href=#special>special</a>
      category, but is not an <code><a href=#the-address-element>address</a></code>, <code><a href=#the-div-element>div</a></code>,
-     or <code><a href=#the-p-element>p</a></code> element, then jump to the last step.</li>
+     or <code><a href=#the-p-element>p</a></code> element, then jump to the step labeled <i>done</i> below.</li>
      <!-- an element <foo> is in this list if the following markup:
 
          <!DOCTYPE html><body><ol><li><foo><li>
@@ -90268,20 +90333,12 @@
      entry in the <a href=#stack-of-open-elements>stack of open elements</a> and return to
      the step labeled <i>loop</i>.</li>
 
-     <li>
+     <li><p><i>Done</i>: If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in
+     button scope">has a <code>p</code> element in button scope</a>, then <a href=#close-a-p-element>close a
+     <code>p</code> element</a>.</li>
 
-      <p>This is the last step.</p>
+     <li><p>Finally, <a href=#insert-an-html-element>insert an HTML element</a> for the token.</li>
 
-      <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
-      an element in button scope">has a <code>p</code> element in button
-      scope</a>, then act as if an end tag with the tag name
-      "p" had been seen.</p>
-
-      <p>Finally, <a href=#insert-an-html-element>insert an HTML element</a> for the
-      token.</p>
-
-     </li>
-
     </ol></dd>
 
    <!-- as normal, but imply </dt> or </dd> when there's another <dt> or <dd> open in weird cases  -->
@@ -90295,14 +90352,44 @@
      <li><p>Initialize <var title="">node</var> to be the <a href=#current-node>current
      node</a> (the bottommost node of the stack).</li>
 
-     <li><p><i>Loop</i>: If <var title="">node</var> is a
-     <code><a href=#the-dd-element>dd</a></code> or <code><a href=#the-dt-element>dt</a></code> element, then act as if an end
-     tag with the same tag name as <var title="">node</var> had been
-     seen, then jump to the last step.</li>
+     <li>
 
+      <p><i>Loop</i>: If <var title="">node</var> is a <code><a href=#the-dd-element>dd</a></code> element, then run these
+      substeps:</p>
+
+      <ol><!-- fake </dd> --><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except for <code><a href=#the-dd-element>dd</a></code> elements.</li>
+
+       <li><p>If the <a href=#current-node>current node</a> is not a <code><a href=#the-dd-element>dd</a></code> element, then this is a
+       <a href=#parse-error>parse error</a>.</li>
+
+       <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until a <code><a href=#the-dd-element>dd</a></code>
+       element has been popped from the stack.</li>
+       <!-- end of fake </dd> -->
+
+       <li><p>Jump to the step labeled <i>done</i> below.</li>
+
+      </ol></li>
+
+     <li>
+
+      <p>If <var title="">node</var> is a <code><a href=#the-dt-element>dt</a></code> element, then run these substeps:</p>
+
+      <ol><!-- fake </dt> --><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except for <code><a href=#the-dt-element>dt</a></code> elements.</li>
+
+       <li><p>If the <a href=#current-node>current node</a> is not a <code><a href=#the-dt-element>dt</a></code> element, then this is a
+       <a href=#parse-error>parse error</a>.</li>
+
+       <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until a <code><a href=#the-dt-element>dt</a></code>
+       element has been popped from the stack.</li>
+       <!-- end of fake </dt> -->
+
+       <li><p>Jump to the step labeled <i>done</i> below.</li>
+
+      </ol></li>
+
      <li><p>If <var title="">node</var> is in the <a href=#special>special</a>
      category, but is not an <code><a href=#the-address-element>address</a></code>, <code><a href=#the-div-element>div</a></code>,
-     or <code><a href=#the-p-element>p</a></code> element, then jump to the last step.</li>
+     or <code><a href=#the-p-element>p</a></code> element, then jump to the step labeled <i>done</i> below.</li>
      <!-- an element <foo> is in this list if the following markup:
 
          <!DOCTYPE html><body><dl><dt><foo><dt>
@@ -90315,20 +90402,12 @@
      entry in the <a href=#stack-of-open-elements>stack of open elements</a> and return to
      the step labeled <i>loop</i>.</li>
 
-     <li>
+     <li><p><i>Done</i>: If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in
+     button scope">has a <code>p</code> element in button scope</a>, then <a href=#close-a-p-element>close a
+     <code>p</code> element</a>.</li>
 
-      <p>This is the last step.</p>
+     <li><p>Finally, <a href=#insert-an-html-element>insert an HTML element</a> for the token.</li>
 
-      <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
-      an element in button scope">has a <code>p</code> element in button
-      scope</a>, then act as if an end tag with the tag name
-      "p" had been seen.</p>
-
-      <p>Finally, <a href=#insert-an-html-element>insert an HTML element</a> for the
-      token.</p>
-
-     </li>
-
     </ol></dd>
 
    <!-- same as normal, but effectively ends parsing -->
@@ -90337,8 +90416,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
 
@@ -90355,23 +90433,28 @@
    <dt>A start tag whose tag name is "button"</dt>
    <dd>
 
-    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-scope title="has
-    an element in scope">has a <code>button</code> element in
-    scope</a>, then this is a <a href=#parse-error>parse error</a>;
-    act as if an end tag with the tag name "button" had been seen,
-    then reprocess the token.</p>
+    <ol><li>
 
-    <p>Otherwise:</p>
+      <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-scope title="has an element in scope">has a
+      <code>button</code> element in scope</a>, then run these substeps:</p>
 
-    <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if
-    any.</p>
+      <ol><li><p><a href=#parse-error>Parse error</a>.</li>
 
-    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
+       <li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</li>
 
-    <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
+       <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until a <code><a href=#the-button-element>button</a></code>
+       element has been popped from the stack.</li>
 
-   </dd>
+      </ol></li>
 
+     <li><p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</li>
+
+     <li><p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</li>
+
+     <li><p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</li>
+
+    </ol></dd>
+
    <!-- end tags for non-phrasing flow content elements (and button) -->
 
    <!-- the normal ones -->
@@ -90432,26 +90515,15 @@
    <dt>An end tag whose tag name is "p"</dt>
    <dd>
 
-    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-button-scope title="has an element in button scope">have an element in button
-    scope</a> with the same tag name as that of the token, then this
-    is a <a href=#parse-error>parse error</a>; act as if a start tag with the tag
-    name "p" had been seen, then reprocess the current token.</p>
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-button-scope title="has an element in button
+    scope">have a <code>p</code> element in button scope</a>, then this is a <a href=#parse-error>parse
+    error</a>; <a href=#insert-an-html-element>insert an HTML element</a> for a "p" start tag token with no
+    attributes.</p>
 
-    <p>Otherwise, run these steps:</p>
+    <p><a href=#close-a-p-element>Close a <code>p</code> element</a>.</p>
 
-    <ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except
-     for elements with the same tag name as the token.</li>
+   </dd>
 
-     <li><p>If the <a href=#current-node>current node</a> is not an element with
-     the same tag name as that of the token, then this is a
-     <a href=#parse-error>parse error</a>.</li>
-
-     <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>
-     until an element with the same tag name as the token has been
-     popped from the stack.</li>
-
-    </ol></dd>
-
    <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> -->
    <dt>An end tag whose tag name is "li"</dt>
    <dd>
@@ -90809,8 +90881,8 @@
     <p>If the <code><a href=#document>Document</a></code> is <em>not</em> set to
     <a href=#quirks-mode>quirks mode</a>, and the <a href=#stack-of-open-elements>stack of open
     elements</a> <a href=#has-an-element-in-button-scope title="has an element in button scope">has a
-    <code>p</code> element in button scope</a>, then act as if an
-    end tag with the tag name "p" had been seen.</p> <!-- i hate
+    <code>p</code> element in button scope</a>, then <a href=#close-a-p-element>close a
+    <code>p</code> element</a>.</p> <!-- i hate
     myself (this quirk was basically caused by acid2; if i'd realised
     we could change the specs when i wrote acid2, we could have
     avoided having any parsing-mode quirks) -Hixie -->
@@ -90823,6 +90895,16 @@
 
    </dd>
 
+   <dt>An end tag whose tag name is "br"</dt>
+   <dd>
+
+    <p><a href=#parse-error>Parse error</a>. Act as described in the next entry, as if this was a "br" start tag
+    token, rather than an end tag token.</p>
+
+   </dd>
+
+   <!-- do not insert things here, since the previous entry refers to the next entry -->
+
    <dt>A start tag whose tag name is one of: "area", "br", "embed",
    "img", "keygen", "wbr"</dt>
    <dd>
@@ -90879,8 +90961,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Immediately
     pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
@@ -90917,40 +90998,59 @@
     included the /, they're not supposed to be including the tag at
     all! -->
 
-    <p>Act as if a start tag token with the tag name "form" had been seen.</p>
+    <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
 
+    <!-- fake <form> -->
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
+    an element in button scope">has a <code>p</code> element in button
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
+
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "form" start tag token with no attributes, and set the
+    <a href=#form-element-pointer><code title=form>form</code> element pointer</a> to
+    point to the element created.</p>
+
     <p>If the token has an attribute called "action", set the
     <code title=attr-fs-action><a href=#attr-fs-action>action</a></code> attribute on the
     resulting <code><a href=#the-form-element>form</a></code> element to the value of the
     "action" attribute of the token.</p>
 
-    <p>Act as if a start tag token with the tag name "hr" had been
-    seen.</p>
+    <!-- fake <hr> -->
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for an "hr" start tag token with no attributes.
+    Immediately pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
-    <p>Act as if a start tag token with the tag name "label" had been
-    seen.</p>
+    <!-- fake <label> -->
+    <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p>
 
-    <p>Act as if a stream of character tokens had been seen (see below
-    for what they should say).</p>
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "label" start tag token with no attributes.</p>
 
-    <p>Act as if a start tag token with the tag name "input" had been
-    seen, with all the attributes from the "isindex" token except
-    "name", "action", and "prompt". Set the <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute of the resulting
-    <code><a href=#the-input-element>input</a></code> element to the value "<code title=attr-fe-name-isindex><a href=#attr-fe-name-isindex>isindex</a></code>".</p>
+    <!-- fake text -->
+    <p><a href=#insert-a-character title="insert a character">Insert characters</a> (see below for <a href=#attr-isindex-prompt title=attr-isindex-prompt>what they should
+    say</a>).</p>
 
-    <p>Act as if a stream of character tokens had been seen (see
-    below for what they should say).</p>
+    <!-- fake <input> -->
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for an "input" start tag token with all the attributes
+    from the "isindex" token except "name", "action", and "prompt", and with an attribute named
+    "name" with the value "isindex". (This creates an <code><a href=#the-input-element>input</a></code> element with the <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute set to the magic balue "<code title=attr-fe-name-isindex><a href=#attr-fe-name-isindex>isindex</a></code>".) Immediately pop the <a href=#current-node>current node</a> off
+    the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
-    <p>Act as if an end tag token with the tag name "label" had been
-    seen.</p>
+    <!-- fake text -->
+    <p><a href=#insert-a-character title="insert a character">Insert more characters</a> (see below for <a href=#attr-isindex-prompt title=attr-isindex-prompt>what they
+    should say</a>).</p>
 
-    <p>Act as if a start tag token with the tag name "hr" had been
-    seen.</p>
+    <!-- fake </label> -->
+    <p>Pop the <a href=#current-node>current node</a> (which will be the <code><a href=#the-label-element>label</a></code> element created
+    earlier) off the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
-    <p>Act as if an end tag token with the tag name "form" had been
-    seen.</p>
+    <!-- fake <hr> -->
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for an "hr" start tag token with no attributes.
+    Immediately pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
-    <p>If the token has an attribute with the name "prompt", then the
+    <!-- fake </form> -->
+    <p>Pop the <a href=#current-node>current node</a> (which will be the <code><a href=#the-form-element>form</a></code> element created
+    earlier) off the <a href=#stack-of-open-elements>stack of open elements</a>. Set the <a href=#form-element-pointer><code title=form>form</code> element pointer</a> to null.</p>
+
+    <!-- explanation of text -->
+    <p><dfn id=attr-isindex-prompt title=attr-isindex-prompt><strong>Prompt</strong></dfn>: If the token has an attribute with the name "prompt", then the
     first stream of characters must be the same string as given in
     that attribute, and the second stream of characters must be
     empty. Otherwise, the two streams of character tokens together
@@ -90993,8 +91093,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if
     any.</p>
@@ -91045,8 +91144,7 @@
    <dd>
 
     <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-option-element>option</a></code>
-    element, then act as if an end tag with the tag name "option" had
-    been seen.</p>
+    element, then pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
     <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if
     any.</p>
@@ -91090,12 +91188,6 @@
 
    </dd>
 
-   <dt>An end tag whose tag name is "br"</dt>
-   <dd>
-    <p><a href=#parse-error>Parse error</a>. Act as if a start tag token with
-    the tag name "br" had been seen. Ignore the end tag token.</p>
-   </dd>
-
    <dt>A start tag whose tag name is "math"</dt>
    <dd>
 
@@ -91229,8 +91321,19 @@
 
     </ol></dd>
 
-  </dl><h6 id=parsing-main-incdata><span class=secno>12.2.5.4.8 </span>The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h6>
+  </dl><p>When the steps above say the user agent is to <dfn id=close-a-p-element>close a <code>p</code> element</dfn>, it
+  means that the user agent must run the following steps:</p>
 
+  <ol><!-- prereq: p in scope --><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except for <code><a href=#the-p-element>p</a></code> elements.</li>
+
+   <li><p>If the <a href=#current-node>current node</a> is not a <code><a href=#the-p-element>p</a></code> element, then this is a
+   <a href=#parse-error>parse error</a>.</li>
+
+   <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until a <code><a href=#the-p-element>p</a></code> element
+   has been popped from the stack.</li>
+
+  </ol><h6 id=parsing-main-incdata><span class=secno>12.2.5.4.8 </span>The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h6>
+
   <p>When the user agent is to apply the rules for the "<a href=#parsing-main-incdata title="insertion mode: text">text</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A character token</dt>
@@ -91430,8 +91533,18 @@
 
    <dt>A start tag whose tag name is "col"</dt>
    <dd>
-    <p>Act as if a start tag token with the tag name "colgroup"
-    had been seen, then reprocess the current token.</p>
+
+    <!-- fake <colgroup> -->
+    <p><a href=#clear-the-stack-back-to-a-table-context>Clear the stack back to a table context</a>. (See
+    below.)</p>
+
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "colgroup" start tag token with no attributes, then
+    switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column
+    group</a>".</p>
+    <!-- end of fake <colgroup> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
    <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt>
@@ -91448,17 +91561,39 @@
 
    <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt>
    <dd>
-    <p>Act as if a start tag token with the tag name "tbody" had
-    been seen, then reprocess the current token.</p>
+
+    <!-- fake <colgroup> -->
+    <p><a href=#clear-the-stack-back-to-a-table-context>Clear the stack back to a table context</a>. (See
+    below.)</p>
+
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "tbody" start tag token with no attributes, then
+    switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intbody title="insertion mode: in table body">in table
+    body</a>".</p>
+    <!-- end of fake <colgroup> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
    <dt>A start tag whose tag name is "table"</dt>
    <dd>
 
-    <p><a href=#parse-error>Parse error</a>. Act as if an end tag token with
-    the tag name "table" had been seen, then, if that token wasn't
-    ignored, reprocess the current token.</p>
+    <p><a href=#parse-error>Parse error</a>.</p>
 
+    <!-- fake </table> -->
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table
+    scope</a> with the same tag name as the token, ignore the token.</p> <!-- fragment case? -->
+
+    <p>Otherwise:</p>
+
+    <p>Pop elements from this stack until a <code><a href=#the-table-element>table</a></code>
+    element has been popped from the stack.</p>
+
+    <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
+    <!-- end of fake </table> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is "table"</dt>
@@ -91466,7 +91601,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table
     scope</a> with the same tag name as the token, this is a
-    <a href=#parse-error>parse error</a>. Ignore the token.</p>
+    <a href=#parse-error>parse error</a>. Ignore the token.</p> <!-- fragment case? -->
 
     <p>Otherwise:</p>
 
@@ -91662,13 +91797,26 @@
    <dt>An end tag whose tag name is "table"</dt>
    <dd>
 
-    <p><a href=#parse-error>Parse error</a>. Act as if an end tag with the tag
-    name "caption" had been seen, then, if that token wasn't
-    ignored, reprocess the current token.</p>
+    <p><a href=#parse-error>Parse error</a>.</p>
 
-    <p class=note>The fake end tag token here can only be
-    ignored in the <a href=#fragment-case>fragment case</a>.</p>
+    <!-- fake </caption> -->
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have a <code>caption</code> element in table
+    scope</a>, ignore the token. (<a href=#fragment-case>fragment
+    case</a>)</p>
 
+    <p>Otherwise:</p>
+
+    <p>Pop elements from this stack until a <code><a href=#the-caption-element>caption</a></code>
+    element has been popped from the stack.</p>
+
+    <p><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker>Clear the list of active formatting elements up to
+    the last marker</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p>
+    <!-- end of fake </caption> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "body", "col",
@@ -91760,10 +91908,19 @@
    <dt>Anything else</dt>
    <dd>
 
-    <p>Act as if an end tag with the tag name "colgroup" had been
-    seen, and then, if that token wasn't ignored, reprocess the
-    current token.</p>
+    <!-- fake </colgroup> -->
+    <p>If the <a href=#current-node>current node</a> is not a <code><a href=#the-colgroup-element>colgroup</a></code> element, then this is a <a href=#parse-error>parse
+    error</a>; ignore the token.</p> <!-- e.g. colgroup fragment case, or <template><col></colgroup> -->
 
+    <p>Otherwise, pop the <a href=#current-node>current node</a> from the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to
+    "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p>
+    <!-- end of fake </colgroup> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
   </dl><h6 id=parsing-main-intbody><span class=secno>12.2.5.4.13 </span>The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h6>
@@ -91784,9 +91941,20 @@
 
    <dt>A start tag whose tag name is one of: "th", "td"</dt>
    <dd>
-    <p><a href=#parse-error>Parse error</a>. Act as if a start tag with
-    the tag name "tr" had been seen, then reprocess the current
-    token.</p>
+
+    <p><a href=#parse-error>Parse error</a>.</p>
+
+    <!-- fake </tr> -->
+    <p><a href=#clear-the-stack-back-to-a-table-body-context>Clear the stack back to a table body
+    context</a>. (See below.)</p>
+
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "tr" start tag token with no attributes, then switch
+    the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intr title="insertion mode:
+    in row">in row</a>".</p>
+    <!-- end of fake </tr> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
@@ -91823,10 +91991,14 @@
     <p><a href=#clear-the-stack-back-to-a-table-body-context>Clear the stack back to a table body
     context</a>. (See below.)</p>
 
-    <p>Act as if an end tag with the same tag name as the
-    <a href=#current-node>current node</a> ("tbody", "tfoot", or "thead") had
-    been seen, then reprocess the current token.</p>
+    <!-- fake </tbody>, </tfoot>, or </thead>, whatever is the current node -->
+    <p>Pop the <a href=#current-node>current node</a> from the <a href=#stack-of-open-elements>stack of
+    open elements</a>. Switch the <a href=#insertion-mode>insertion mode</a>
+    to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p>
+    <!-- end of fake </tbody>, </tfoot>, or </thead>, whatever was the current node -->
 
+    <p>Reprocess the current token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "body", "caption",
@@ -91877,7 +92049,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table
     scope</a> with the same tag name as the token, this is a
-    <a href=#parse-error>parse error</a>. Ignore the token.</p>
+    <a href=#parse-error>parse error</a>. Ignore the token.</p> <!-- fragment case? -->
 
     <p>Otherwise:</p>
 
@@ -91897,10 +92069,25 @@
    <dt>An end tag whose tag name is "table"</dt>
    <dd>
 
-    <p>Act as if an end tag with the tag name "tr" had been seen,
-    then, if that token wasn't ignored, reprocess the current
-    token.</p>
+    <!-- fake <tr> -->
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have a <code>tr</code> element in table
+    scope</a>, this is a
+    <a href=#parse-error>parse error</a>. Ignore the token.</p> <!-- fragment case? -->
 
+    <p>Otherwise:</p>
+
+    <p><a href=#clear-the-stack-back-to-a-table-row-context>Clear the stack back to a table row
+    context</a>. (See below.)</p>
+
+    <p>Pop the <a href=#current-node>current node</a> (which will be a
+    <code><a href=#the-tr-element>tr</a></code> element) from the <a href=#stack-of-open-elements>stack of open
+    elements</a>. Switch the <a href=#insertion-mode>insertion mode</a> to
+    "<a href=#parsing-main-intbody title="insertion mode: in table body">in table
+    body</a>".</p>
+    <!-- end of fake </tr> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
@@ -91911,9 +92098,24 @@
     scope</a> with the same tag name as the token, this is a
     <a href=#parse-error>parse error</a>. Ignore the token.</p>
 
-    <p>Otherwise, act as if an end tag with the tag name "tr" had
-    been seen, then reprocess the current token.</p>
+    <!-- fake <tr> -->
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have a <code>tr</code> element in table
+    scope</a>, ignore the token.</p> <!-- fragment case? -->
 
+    <p>Otherwise:</p>
+
+    <p><a href=#clear-the-stack-back-to-a-table-row-context>Clear the stack back to a table row
+    context</a>. (See below.)</p>
+
+    <p>Pop the <a href=#current-node>current node</a> (which will be a
+    <code><a href=#the-tr-element>tr</a></code> element) from the <a href=#stack-of-open-elements>stack of open
+    elements</a>. Switch the <a href=#insertion-mode>insertion mode</a> to
+    "<a href=#parsing-main-intbody title="insertion mode: in table body">in table
+    body</a>".</p>
+    <!-- end of fake </tr> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "body", "caption",
@@ -92015,15 +92217,21 @@
   </dl><p>Where the steps above say to <dfn id=close-the-cell>close the cell</dfn>, they
   mean to run the following algorithm:</p>
 
-  <ol><li><p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-table-scope title="has an element in table scope">has a <code>td</code>
-   element in table scope</a>, then act as if an end tag token
-   with the tag name "td" had been seen.</li>
+  <ol><!-- fake </td> or </th> --><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</li>
 
-   <li><p>Otherwise, the <a href=#stack-of-open-elements>stack of open elements</a> will
-   <a href=#has-an-element-in-table-scope title="has an element in table scope">have a
-   <code>th</code> element in table scope</a>; act as if an end
-   tag token with the tag name "th" had been seen.</li>
+   <li><p>If the <a href=#current-node>current node</a> is not now a <code><a href=#the-td-element>td</a></code> element or a <code><a href=#the-th-element>th</a></code>
+   element, then this is a <a href=#parse-error>parse error</a>.</li>
 
+   <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> stack until a <code><a href=#the-td-element>td</a></code>
+   element or a <code><a href=#the-th-element>th</a></code> element has been popped from the stack.</li>
+
+   <li><p><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker>Clear the list of active formatting elements up to the last marker</a>.</li>
+
+   <li><p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intr title="insertion mode: in row">in
+   row</a>".</li> <!-- current node here will be a <tr> normally; but could be <html> in the
+   fragment case, or <template> in the template case -->
+   <!-- end of fake </td> or </th> -->
+
   </ol><p class=note>The <a href=#stack-of-open-elements>stack of open elements</a> cannot have
   both a <code><a href=#the-td-element>td</a></code> and a <code><a href=#the-th-element>th</a></code> element <a href=#has-an-element-in-table-scope title="has an element in table scope">in table scope</a> at the
   same time, nor can it have neither when the <a href=#close-the-cell>close the
@@ -92064,9 +92272,11 @@
    <dt>A start tag whose tag name is "option"</dt>
    <dd>
 
+    <!-- fake </option> (maybe) -->
     <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-option-element>option</a></code>
-    element, act as if an end tag with the tag name "option" had
-    been seen.</p>
+    element, pop that node from the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
+    <!-- end of fake </option> -->
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
 
@@ -92075,13 +92285,17 @@
    <dt>A start tag whose tag name is "optgroup"</dt>
    <dd>
 
+    <!-- fake </option> (maybe) -->
     <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-option-element>option</a></code>
-    element, act as if an end tag with the tag name "option" had
-    been seen.</p>
+    element, pop that node from the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
+    <!-- end of fake </option> -->
 
-    <p>If the <a href=#current-node>current node</a> is an
-    <code><a href=#the-optgroup-element>optgroup</a></code> element, act as if an end tag with the
-    tag name "optgroup" had been seen.</p>
+    <!-- fake </optgroup> (maybe) -->
+    <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-optgroup-element>optgroup</a></code>
+    element, pop that node from the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
+    <!-- end of fake </optgroup> -->
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
 
@@ -92090,11 +92304,13 @@
    <dt>An end tag whose tag name is "optgroup"</dt>
    <dd>
 
+    <!-- fake </option> (maybe) -->
     <p>First, if the <a href=#current-node>current node</a> is an
     <code><a href=#the-option-element>option</a></code> element, and the node immediately before
     it in the <a href=#stack-of-open-elements>stack of open elements</a> is an
-    <code><a href=#the-optgroup-element>optgroup</a></code> element, then act as if an end tag with
-    the tag name "option" had been seen.</p>
+    <code><a href=#the-optgroup-element>optgroup</a></code> element, then pop the <a href=#current-node>current node</a> from the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
+    <!-- end of fake </option> -->
 
     <p>If the <a href=#current-node>current node</a> is an
     <code><a href=#the-optgroup-element>optgroup</a></code> element, then pop that node from the
@@ -92134,9 +92350,18 @@
    <dt>A start tag whose tag name is "select"</dt>
    <dd>
 
-    <p><a href=#parse-error>Parse error</a>. Act as if the token had been
-    an end tag with the tag name "select" instead.</p>
+    <p><a href=#parse-error>Parse error</a>.</p>
 
+    <!-- fake </select> -->
+    <p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>
+    until a <code><a href=#the-select-element>select</a></code> element has been popped from the
+    stack.</p>
+
+    <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
+    <!-- end of fake </select> -->
+
+    <p class=note>It just gets treated like an end tag.</p>
+
    </dd>
 
    <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt>
@@ -92148,9 +92373,16 @@
     element in select scope</a>, ignore the token. (<a href=#fragment-case>fragment
     case</a>)</p>
 
-    <p>Otherwise, act as if an end tag with the tag name "select" had
-    been seen, and reprocess the token.</p>
+    <!-- fake </select> -->
+    <p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>
+    until a <code><a href=#the-select-element>select</a></code> element has been popped from the
+    stack.</p>
 
+    <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
+    <!-- end of fake </select> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>A start tag token whose tag name is "script"</dt>
@@ -92188,8 +92420,19 @@
   <dl class=switch><dt>A start tag whose tag name is one of: "caption", "table",
    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
    <dd>
-    <p><a href=#parse-error>Parse error</a>. Act as if an end tag with the tag
-    name "select" had been seen, and reprocess the token.</p>
+
+    <p><a href=#parse-error>Parse error</a>.</p>
+
+    <!-- fake </select> -->
+    <p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>
+    until a <code><a href=#the-select-element>select</a></code> element has been popped from the
+    stack.</p>
+
+    <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
+    <!-- end of fake </select> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "caption", "table",
@@ -92198,12 +92441,22 @@
 
     <p><a href=#parse-error>Parse error</a>.</p>
 
-    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-table-scope>has an
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an
     element in table scope</a> with the same tag name as that
-    of the token, then act as if an end tag with the tag name
-    "select" had been seen, and reprocess the token. Otherwise,
-    ignore the token.</p>
+    of the token, then ignore the token.</p>
 
+    <p>Otherwise:</p>
+
+    <!-- fake </select> -->
+    <p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>
+    until a <code><a href=#the-select-element>select</a></code> element has been popped from the
+    stack.</p>
+
+    <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
+    <!-- end of fake </select> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>Anything else</dt>
@@ -92323,9 +92576,20 @@
     <p>If there is no <code><a href=#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements>stack of open elements</a>, then
     <a href=#stop-parsing>stop parsing</a>. (<a href=#fragment-case>fragment case</a>)</p>
 
-    <p>Otherwise, this is a <a href=#parse-error>parse error</a>; act as if an end tag with the tag name
-    "template" had been seen and reprocess the current token.</p>
+    <p>Otherwise, this is a <a href=#parse-error>parse error</a>.</p>
 
+    <!-- fake </template> -->
+    <p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until a <code>templtae</code> element has been popped from the stack.</p>
+
+    <p><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker>Clear the list of active formatting elements up to the last marker</a>.</p>
+
+    <p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template insertion modes</a>.</p>
+
+    <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
+    <!-- end of fake </template> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
   </dl><h6 id=parsing-main-afterbody><span class=secno>12.2.5.4.19 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6>

Modified: index
===================================================================
--- index	2013-06-28 22:44:17 UTC (rev 8000)
+++ index	2013-07-01 21:19:49 UTC (rev 8001)
@@ -256,7 +256,7 @@
 
   <header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
    <hgroup><h1 class=allcaps>HTML</h1>
-    <h2 class="no-num no-toc">Living Standard — Last Updated 28 June 2013</h2>
+    <h2 class="no-num no-toc">Living Standard — Last Updated 1 July 2013</h2>
    </hgroup><dl><dt><strong>Web developer edition:</strong></dt>
     <dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
     <dt>Multiple-page version:</dt>
@@ -89584,8 +89584,7 @@
    <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
    <dd>
 
-    <p>Act as if a start tag token with the tag name "head" and no
-    attributes had been seen, then reprocess the current token.</p>
+    <p>Act s described in the "anything else" entry below.</p>
 
    </dd>
 
@@ -89599,10 +89598,19 @@
    <dt>Anything else</dt>
    <dd>
 
-    <p>Act as if a start tag token with the tag name "head" and no
-    attributes had been seen, then reprocess the current
-    token.</p>
+    <!-- fake <head> -->
 
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "head" start tag token with no attributes.</p>
+
+    <p>Set the <a href=#head-element-pointer><code title="">head</code> element pointer</a>
+    to the newly created <code><a href=#the-head-element>head</a></code> element.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>".</p>
+
+    <!-- end of fake <head> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
   </dl><h6 id=parsing-main-inhead><span class=secno>12.2.5.4.4 </span>The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h6>
@@ -89796,8 +89804,7 @@
      <li><p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
      insertion modes</a>.</p>
 
-     <li><p><a href=#reset-the-insertion-mode-appropriately title="reset the insertion mode appropriately">Reset the
-     parser's insertion mode appropriately</a>.</li>
+     <li><p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</li>
 
     </ol></dd>
 
@@ -89812,9 +89819,16 @@
 
     <!-- can't get here with an EOF and a fragment case -->
 
-    <p>Act as if an end tag token with the tag name "head" had
-    been seen, and reprocess the current token.</p>
+    <!-- start of fake </head> -->
+    <p>Pop the <a href=#current-node>current node</a> (which will be the
+    <code><a href=#the-head-element>head</a></code> element) off the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
 
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</a>".</p>
+    <!-- end of fake </head> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
   </dl><h6 id=parsing-main-inheadnoscript><span class=secno>12.2.5.4.5 </span>The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h6>
@@ -89871,10 +89885,19 @@
 
     <!-- can't get here with an EOF and a fragment case -->
 
-    <p><a href=#parse-error>Parse error</a>. Act as if an end tag with the tag
-    name "noscript" had been seen and reprocess the current
-    token.</p>
+    <p><a href=#parse-error>Parse error</a>.</p>
 
+    <!-- fake </noscript> -->
+    <p>Pop the <a href=#current-node>current node</a> (which will be a
+    <code><a href=#the-noscript-element>noscript</a></code> element) from the <a href=#stack-of-open-elements>stack of open
+    elements</a>; the new <a href=#current-node>current node</a> will be a
+    <code><a href=#the-head-element>head</a></code> element.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>".</p>
+    <!-- end fake </noscript> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
   </dl><h6 id=the-after-head-insertion-mode><span class=secno>12.2.5.4.6 </span>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h6>
@@ -89958,10 +89981,15 @@
 
    <dt>Anything else</dt>
    <dd>
-    <p>Act as if a start tag token with the tag name "body" and no
-    attributes had been seen, then set the <a href=#frameset-ok-flag>frameset-ok
-    flag</a> back to "ok", and then reprocess the current
-    token.</p>
+
+    <!-- fake <body>, but without resetting frameset-ok -->
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "body" start tag token with no attributes.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>".</p>
+    <!-- end fake <body> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
   </dl><h6 id=parsing-main-inbody><span class=secno>12.2.5.4.7 </span>The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h6>
@@ -90145,10 +90173,37 @@
    <dt>An end tag whose tag name is "html"</dt>
    <dd>
 
-    <p>Act as if an end tag with tag name "body" had been seen,
-    then, if that token wasn't ignored, reprocess the current
+    <!-- fake </body> -->
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-scope title="has an element in scope">have a <code>body</code> element
+    in scope</a>, this is a <a href=#parse-error>parse error</a>; ignore the
     token.</p>
 
+    <!-- if we get here, the insertion mode here is forcibly "in
+    body". -->
+
+    <p>Otherwise, if there is a node in the <a href=#stack-of-open-elements>stack of open
+    elements</a> that is not either a <code><a href=#the-dd-element>dd</a></code> element, a
+    <code><a href=#the-dt-element>dt</a></code> element, an <code><a href=#the-li-element>li</a></code> element, an
+    <code><a href=#the-optgroup-element>optgroup</a></code> element, an <code><a href=#the-option-element>option</a></code> element, a
+    <code><a href=#the-p-element>p</a></code> element, an <code><a href=#the-rp-element>rp</a></code> element, an
+    <code><a href=#the-rt-element>rt</a></code> element, a <code><a href=#the-tbody-element>tbody</a></code> element, a
+    <code><a href=#the-td-element>td</a></code> element, a <code><a href=#the-tfoot-element>tfoot</a></code> element, a
+    <code><a href=#the-th-element>th</a></code> element, a <code><a href=#the-thead-element>thead</a></code> element, a
+    <code><a href=#the-tr-element>tr</a></code> element, the <code><a href=#the-body-element>body</a></code> element, or the
+    <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
+    error</a>.</p> <!-- (some of those are fragment cases, e.g. for
+    <tbody> you'd have hit the first paragraph since the <body>
+    wouldn't be in scope, unless it was a fragment case) -->
+
+    <!-- If we ever change the frameset-ok flag to an insertion mode,
+    then we'd have to somehow keep track of its state when we switch
+    to after-body. -->
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-afterbody title="insertion mode: after body">after body</a>".</p>
+    <!-- end fake </body> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <!-- start tags for non-phrasing flow content elements -->
@@ -90167,8 +90222,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an
     element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name "p" had
-    been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
 
@@ -90181,8 +90235,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p>If the <a href=#current-node>current node</a> is an element whose tag name
     is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
@@ -90200,8 +90253,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
 
@@ -90229,8 +90281,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token, and set the
     <a href=#form-element-pointer><code title=form>form</code> element pointer</a> to
@@ -90249,13 +90300,27 @@
      <li><p>Initialize <var title="">node</var> to be the <a href=#current-node>current
      node</a> (the bottommost node of the stack).</li>
 
-     <li><p><i>Loop</i>: If <var title="">node</var> is an
-     <code><a href=#the-li-element>li</a></code> element, then act as if an end tag with the tag
-     name "li" had been seen, then jump to the last step.</li>
+     <li>
 
+      <p><i>Loop</i>: If <var title="">node</var> is an <code><a href=#the-li-element>li</a></code> element, then run these
+      substeps:</p>
+
+      <ol><!-- fake </li> --><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except for <code><a href=#the-li-element>li</a></code> elements.</li>
+
+       <li><p>If the <a href=#current-node>current node</a> is not an <code><a href=#the-li-element>li</a></code> element, then this is a
+       <a href=#parse-error>parse error</a>.</li>
+
+       <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until an <code><a href=#the-li-element>li</a></code>
+       element has been popped from the stack.</li>
+       <!-- end of fake </li> -->
+
+       <li><p>Jump to the step labeled <i>done</i> below.</li>
+
+      </ol></li>
+
      <li><p>If <var title="">node</var> is in the <a href=#special>special</a>
      category, but is not an <code><a href=#the-address-element>address</a></code>, <code><a href=#the-div-element>div</a></code>,
-     or <code><a href=#the-p-element>p</a></code> element, then jump to the last step.</li>
+     or <code><a href=#the-p-element>p</a></code> element, then jump to the step labeled <i>done</i> below.</li>
      <!-- an element <foo> is in this list if the following markup:
 
          <!DOCTYPE html><body><ol><li><foo><li>
@@ -90268,20 +90333,12 @@
      entry in the <a href=#stack-of-open-elements>stack of open elements</a> and return to
      the step labeled <i>loop</i>.</li>
 
-     <li>
+     <li><p><i>Done</i>: If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in
+     button scope">has a <code>p</code> element in button scope</a>, then <a href=#close-a-p-element>close a
+     <code>p</code> element</a>.</li>
 
-      <p>This is the last step.</p>
+     <li><p>Finally, <a href=#insert-an-html-element>insert an HTML element</a> for the token.</li>
 
-      <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
-      an element in button scope">has a <code>p</code> element in button
-      scope</a>, then act as if an end tag with the tag name
-      "p" had been seen.</p>
-
-      <p>Finally, <a href=#insert-an-html-element>insert an HTML element</a> for the
-      token.</p>
-
-     </li>
-
     </ol></dd>
 
    <!-- as normal, but imply </dt> or </dd> when there's another <dt> or <dd> open in weird cases  -->
@@ -90295,14 +90352,44 @@
      <li><p>Initialize <var title="">node</var> to be the <a href=#current-node>current
      node</a> (the bottommost node of the stack).</li>
 
-     <li><p><i>Loop</i>: If <var title="">node</var> is a
-     <code><a href=#the-dd-element>dd</a></code> or <code><a href=#the-dt-element>dt</a></code> element, then act as if an end
-     tag with the same tag name as <var title="">node</var> had been
-     seen, then jump to the last step.</li>
+     <li>
 
+      <p><i>Loop</i>: If <var title="">node</var> is a <code><a href=#the-dd-element>dd</a></code> element, then run these
+      substeps:</p>
+
+      <ol><!-- fake </dd> --><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except for <code><a href=#the-dd-element>dd</a></code> elements.</li>
+
+       <li><p>If the <a href=#current-node>current node</a> is not a <code><a href=#the-dd-element>dd</a></code> element, then this is a
+       <a href=#parse-error>parse error</a>.</li>
+
+       <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until a <code><a href=#the-dd-element>dd</a></code>
+       element has been popped from the stack.</li>
+       <!-- end of fake </dd> -->
+
+       <li><p>Jump to the step labeled <i>done</i> below.</li>
+
+      </ol></li>
+
+     <li>
+
+      <p>If <var title="">node</var> is a <code><a href=#the-dt-element>dt</a></code> element, then run these substeps:</p>
+
+      <ol><!-- fake </dt> --><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except for <code><a href=#the-dt-element>dt</a></code> elements.</li>
+
+       <li><p>If the <a href=#current-node>current node</a> is not a <code><a href=#the-dt-element>dt</a></code> element, then this is a
+       <a href=#parse-error>parse error</a>.</li>
+
+       <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until a <code><a href=#the-dt-element>dt</a></code>
+       element has been popped from the stack.</li>
+       <!-- end of fake </dt> -->
+
+       <li><p>Jump to the step labeled <i>done</i> below.</li>
+
+      </ol></li>
+
      <li><p>If <var title="">node</var> is in the <a href=#special>special</a>
      category, but is not an <code><a href=#the-address-element>address</a></code>, <code><a href=#the-div-element>div</a></code>,
-     or <code><a href=#the-p-element>p</a></code> element, then jump to the last step.</li>
+     or <code><a href=#the-p-element>p</a></code> element, then jump to the step labeled <i>done</i> below.</li>
      <!-- an element <foo> is in this list if the following markup:
 
          <!DOCTYPE html><body><dl><dt><foo><dt>
@@ -90315,20 +90402,12 @@
      entry in the <a href=#stack-of-open-elements>stack of open elements</a> and return to
      the step labeled <i>loop</i>.</li>
 
-     <li>
+     <li><p><i>Done</i>: If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has an element in
+     button scope">has a <code>p</code> element in button scope</a>, then <a href=#close-a-p-element>close a
+     <code>p</code> element</a>.</li>
 
-      <p>This is the last step.</p>
+     <li><p>Finally, <a href=#insert-an-html-element>insert an HTML element</a> for the token.</li>
 
-      <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
-      an element in button scope">has a <code>p</code> element in button
-      scope</a>, then act as if an end tag with the tag name
-      "p" had been seen.</p>
-
-      <p>Finally, <a href=#insert-an-html-element>insert an HTML element</a> for the
-      token.</p>
-
-     </li>
-
     </ol></dd>
 
    <!-- same as normal, but effectively ends parsing -->
@@ -90337,8 +90416,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
 
@@ -90355,23 +90433,28 @@
    <dt>A start tag whose tag name is "button"</dt>
    <dd>
 
-    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-scope title="has
-    an element in scope">has a <code>button</code> element in
-    scope</a>, then this is a <a href=#parse-error>parse error</a>;
-    act as if an end tag with the tag name "button" had been seen,
-    then reprocess the token.</p>
+    <ol><li>
 
-    <p>Otherwise:</p>
+      <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-scope title="has an element in scope">has a
+      <code>button</code> element in scope</a>, then run these substeps:</p>
 
-    <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if
-    any.</p>
+      <ol><li><p><a href=#parse-error>Parse error</a>.</li>
 
-    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
+       <li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</li>
 
-    <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
+       <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until a <code><a href=#the-button-element>button</a></code>
+       element has been popped from the stack.</li>
 
-   </dd>
+      </ol></li>
 
+     <li><p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</li>
+
+     <li><p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</li>
+
+     <li><p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</li>
+
+    </ol></dd>
+
    <!-- end tags for non-phrasing flow content elements (and button) -->
 
    <!-- the normal ones -->
@@ -90432,26 +90515,15 @@
    <dt>An end tag whose tag name is "p"</dt>
    <dd>
 
-    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-button-scope title="has an element in button scope">have an element in button
-    scope</a> with the same tag name as that of the token, then this
-    is a <a href=#parse-error>parse error</a>; act as if a start tag with the tag
-    name "p" had been seen, then reprocess the current token.</p>
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-button-scope title="has an element in button
+    scope">have a <code>p</code> element in button scope</a>, then this is a <a href=#parse-error>parse
+    error</a>; <a href=#insert-an-html-element>insert an HTML element</a> for a "p" start tag token with no
+    attributes.</p>
 
-    <p>Otherwise, run these steps:</p>
+    <p><a href=#close-a-p-element>Close a <code>p</code> element</a>.</p>
 
-    <ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except
-     for elements with the same tag name as the token.</li>
+   </dd>
 
-     <li><p>If the <a href=#current-node>current node</a> is not an element with
-     the same tag name as that of the token, then this is a
-     <a href=#parse-error>parse error</a>.</li>
-
-     <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>
-     until an element with the same tag name as the token has been
-     popped from the stack.</li>
-
-    </ol></dd>
-
    <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> -->
    <dt>An end tag whose tag name is "li"</dt>
    <dd>
@@ -90809,8 +90881,8 @@
     <p>If the <code><a href=#document>Document</a></code> is <em>not</em> set to
     <a href=#quirks-mode>quirks mode</a>, and the <a href=#stack-of-open-elements>stack of open
     elements</a> <a href=#has-an-element-in-button-scope title="has an element in button scope">has a
-    <code>p</code> element in button scope</a>, then act as if an
-    end tag with the tag name "p" had been seen.</p> <!-- i hate
+    <code>p</code> element in button scope</a>, then <a href=#close-a-p-element>close a
+    <code>p</code> element</a>.</p> <!-- i hate
     myself (this quirk was basically caused by acid2; if i'd realised
     we could change the specs when i wrote acid2, we could have
     avoided having any parsing-mode quirks) -Hixie -->
@@ -90823,6 +90895,16 @@
 
    </dd>
 
+   <dt>An end tag whose tag name is "br"</dt>
+   <dd>
+
+    <p><a href=#parse-error>Parse error</a>. Act as described in the next entry, as if this was a "br" start tag
+    token, rather than an end tag token.</p>
+
+   </dd>
+
+   <!-- do not insert things here, since the previous entry refers to the next entry -->
+
    <dt>A start tag whose tag name is one of: "area", "br", "embed",
    "img", "keygen", "wbr"</dt>
    <dd>
@@ -90879,8 +90961,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token. Immediately
     pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
@@ -90917,40 +90998,59 @@
     included the /, they're not supposed to be including the tag at
     all! -->
 
-    <p>Act as if a start tag token with the tag name "form" had been seen.</p>
+    <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
 
+    <!-- fake <form> -->
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
+    an element in button scope">has a <code>p</code> element in button
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
+
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "form" start tag token with no attributes, and set the
+    <a href=#form-element-pointer><code title=form>form</code> element pointer</a> to
+    point to the element created.</p>
+
     <p>If the token has an attribute called "action", set the
     <code title=attr-fs-action><a href=#attr-fs-action>action</a></code> attribute on the
     resulting <code><a href=#the-form-element>form</a></code> element to the value of the
     "action" attribute of the token.</p>
 
-    <p>Act as if a start tag token with the tag name "hr" had been
-    seen.</p>
+    <!-- fake <hr> -->
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for an "hr" start tag token with no attributes.
+    Immediately pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
-    <p>Act as if a start tag token with the tag name "label" had been
-    seen.</p>
+    <!-- fake <label> -->
+    <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p>
 
-    <p>Act as if a stream of character tokens had been seen (see below
-    for what they should say).</p>
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "label" start tag token with no attributes.</p>
 
-    <p>Act as if a start tag token with the tag name "input" had been
-    seen, with all the attributes from the "isindex" token except
-    "name", "action", and "prompt". Set the <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute of the resulting
-    <code><a href=#the-input-element>input</a></code> element to the value "<code title=attr-fe-name-isindex><a href=#attr-fe-name-isindex>isindex</a></code>".</p>
+    <!-- fake text -->
+    <p><a href=#insert-a-character title="insert a character">Insert characters</a> (see below for <a href=#attr-isindex-prompt title=attr-isindex-prompt>what they should
+    say</a>).</p>
 
-    <p>Act as if a stream of character tokens had been seen (see
-    below for what they should say).</p>
+    <!-- fake <input> -->
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for an "input" start tag token with all the attributes
+    from the "isindex" token except "name", "action", and "prompt", and with an attribute named
+    "name" with the value "isindex". (This creates an <code><a href=#the-input-element>input</a></code> element with the <code title=attr-fe-name><a href=#attr-fe-name>name</a></code> attribute set to the magic balue "<code title=attr-fe-name-isindex><a href=#attr-fe-name-isindex>isindex</a></code>".) Immediately pop the <a href=#current-node>current node</a> off
+    the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
-    <p>Act as if an end tag token with the tag name "label" had been
-    seen.</p>
+    <!-- fake text -->
+    <p><a href=#insert-a-character title="insert a character">Insert more characters</a> (see below for <a href=#attr-isindex-prompt title=attr-isindex-prompt>what they
+    should say</a>).</p>
 
-    <p>Act as if a start tag token with the tag name "hr" had been
-    seen.</p>
+    <!-- fake </label> -->
+    <p>Pop the <a href=#current-node>current node</a> (which will be the <code><a href=#the-label-element>label</a></code> element created
+    earlier) off the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
-    <p>Act as if an end tag token with the tag name "form" had been
-    seen.</p>
+    <!-- fake <hr> -->
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for an "hr" start tag token with no attributes.
+    Immediately pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
-    <p>If the token has an attribute with the name "prompt", then the
+    <!-- fake </form> -->
+    <p>Pop the <a href=#current-node>current node</a> (which will be the <code><a href=#the-form-element>form</a></code> element created
+    earlier) off the <a href=#stack-of-open-elements>stack of open elements</a>. Set the <a href=#form-element-pointer><code title=form>form</code> element pointer</a> to null.</p>
+
+    <!-- explanation of text -->
+    <p><dfn id=attr-isindex-prompt title=attr-isindex-prompt><strong>Prompt</strong></dfn>: If the token has an attribute with the name "prompt", then the
     first stream of characters must be the same string as given in
     that attribute, and the second stream of characters must be
     empty. Otherwise, the two streams of character tokens together
@@ -90993,8 +91093,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-button-scope title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</a>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</a>, then <a href=#close-a-p-element>close a <code>p</code> element</a>.</p>
 
     <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if
     any.</p>
@@ -91045,8 +91144,7 @@
    <dd>
 
     <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-option-element>option</a></code>
-    element, then act as if an end tag with the tag name "option" had
-    been seen.</p>
+    element, then pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
     <p><a href=#reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if
     any.</p>
@@ -91090,12 +91188,6 @@
 
    </dd>
 
-   <dt>An end tag whose tag name is "br"</dt>
-   <dd>
-    <p><a href=#parse-error>Parse error</a>. Act as if a start tag token with
-    the tag name "br" had been seen. Ignore the end tag token.</p>
-   </dd>
-
    <dt>A start tag whose tag name is "math"</dt>
    <dd>
 
@@ -91229,8 +91321,19 @@
 
     </ol></dd>
 
-  </dl><h6 id=parsing-main-incdata><span class=secno>12.2.5.4.8 </span>The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h6>
+  </dl><p>When the steps above say the user agent is to <dfn id=close-a-p-element>close a <code>p</code> element</dfn>, it
+  means that the user agent must run the following steps:</p>
 
+  <ol><!-- prereq: p in scope --><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>, except for <code><a href=#the-p-element>p</a></code> elements.</li>
+
+   <li><p>If the <a href=#current-node>current node</a> is not a <code><a href=#the-p-element>p</a></code> element, then this is a
+   <a href=#parse-error>parse error</a>.</li>
+
+   <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until a <code><a href=#the-p-element>p</a></code> element
+   has been popped from the stack.</li>
+
+  </ol><h6 id=parsing-main-incdata><span class=secno>12.2.5.4.8 </span>The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h6>
+
   <p>When the user agent is to apply the rules for the "<a href=#parsing-main-incdata title="insertion mode: text">text</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A character token</dt>
@@ -91430,8 +91533,18 @@
 
    <dt>A start tag whose tag name is "col"</dt>
    <dd>
-    <p>Act as if a start tag token with the tag name "colgroup"
-    had been seen, then reprocess the current token.</p>
+
+    <!-- fake <colgroup> -->
+    <p><a href=#clear-the-stack-back-to-a-table-context>Clear the stack back to a table context</a>. (See
+    below.)</p>
+
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "colgroup" start tag token with no attributes, then
+    switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column
+    group</a>".</p>
+    <!-- end of fake <colgroup> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
    <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt>
@@ -91448,17 +91561,39 @@
 
    <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt>
    <dd>
-    <p>Act as if a start tag token with the tag name "tbody" had
-    been seen, then reprocess the current token.</p>
+
+    <!-- fake <colgroup> -->
+    <p><a href=#clear-the-stack-back-to-a-table-context>Clear the stack back to a table context</a>. (See
+    below.)</p>
+
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "tbody" start tag token with no attributes, then
+    switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intbody title="insertion mode: in table body">in table
+    body</a>".</p>
+    <!-- end of fake <colgroup> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
    <dt>A start tag whose tag name is "table"</dt>
    <dd>
 
-    <p><a href=#parse-error>Parse error</a>. Act as if an end tag token with
-    the tag name "table" had been seen, then, if that token wasn't
-    ignored, reprocess the current token.</p>
+    <p><a href=#parse-error>Parse error</a>.</p>
 
+    <!-- fake </table> -->
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table
+    scope</a> with the same tag name as the token, ignore the token.</p> <!-- fragment case? -->
+
+    <p>Otherwise:</p>
+
+    <p>Pop elements from this stack until a <code><a href=#the-table-element>table</a></code>
+    element has been popped from the stack.</p>
+
+    <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
+    <!-- end of fake </table> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is "table"</dt>
@@ -91466,7 +91601,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table
     scope</a> with the same tag name as the token, this is a
-    <a href=#parse-error>parse error</a>. Ignore the token.</p>
+    <a href=#parse-error>parse error</a>. Ignore the token.</p> <!-- fragment case? -->
 
     <p>Otherwise:</p>
 
@@ -91662,13 +91797,26 @@
    <dt>An end tag whose tag name is "table"</dt>
    <dd>
 
-    <p><a href=#parse-error>Parse error</a>. Act as if an end tag with the tag
-    name "caption" had been seen, then, if that token wasn't
-    ignored, reprocess the current token.</p>
+    <p><a href=#parse-error>Parse error</a>.</p>
 
-    <p class=note>The fake end tag token here can only be
-    ignored in the <a href=#fragment-case>fragment case</a>.</p>
+    <!-- fake </caption> -->
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have a <code>caption</code> element in table
+    scope</a>, ignore the token. (<a href=#fragment-case>fragment
+    case</a>)</p>
 
+    <p>Otherwise:</p>
+
+    <p>Pop elements from this stack until a <code><a href=#the-caption-element>caption</a></code>
+    element has been popped from the stack.</p>
+
+    <p><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker>Clear the list of active formatting elements up to
+    the last marker</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p>
+    <!-- end of fake </caption> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "body", "col",
@@ -91760,10 +91908,19 @@
    <dt>Anything else</dt>
    <dd>
 
-    <p>Act as if an end tag with the tag name "colgroup" had been
-    seen, and then, if that token wasn't ignored, reprocess the
-    current token.</p>
+    <!-- fake </colgroup> -->
+    <p>If the <a href=#current-node>current node</a> is not a <code><a href=#the-colgroup-element>colgroup</a></code> element, then this is a <a href=#parse-error>parse
+    error</a>; ignore the token.</p> <!-- e.g. colgroup fragment case, or <template><col></colgroup> -->
 
+    <p>Otherwise, pop the <a href=#current-node>current node</a> from the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to
+    "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p>
+    <!-- end of fake </colgroup> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
   </dl><h6 id=parsing-main-intbody><span class=secno>12.2.5.4.13 </span>The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h6>
@@ -91784,9 +91941,20 @@
 
    <dt>A start tag whose tag name is one of: "th", "td"</dt>
    <dd>
-    <p><a href=#parse-error>Parse error</a>. Act as if a start tag with
-    the tag name "tr" had been seen, then reprocess the current
-    token.</p>
+
+    <p><a href=#parse-error>Parse error</a>.</p>
+
+    <!-- fake </tr> -->
+    <p><a href=#clear-the-stack-back-to-a-table-body-context>Clear the stack back to a table body
+    context</a>. (See below.)</p>
+
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for a "tr" start tag token with no attributes, then switch
+    the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intr title="insertion mode:
+    in row">in row</a>".</p>
+    <!-- end of fake </tr> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
@@ -91823,10 +91991,14 @@
     <p><a href=#clear-the-stack-back-to-a-table-body-context>Clear the stack back to a table body
     context</a>. (See below.)</p>
 
-    <p>Act as if an end tag with the same tag name as the
-    <a href=#current-node>current node</a> ("tbody", "tfoot", or "thead") had
-    been seen, then reprocess the current token.</p>
+    <!-- fake </tbody>, </tfoot>, or </thead>, whatever is the current node -->
+    <p>Pop the <a href=#current-node>current node</a> from the <a href=#stack-of-open-elements>stack of
+    open elements</a>. Switch the <a href=#insertion-mode>insertion mode</a>
+    to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p>
+    <!-- end of fake </tbody>, </tfoot>, or </thead>, whatever was the current node -->
 
+    <p>Reprocess the current token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "body", "caption",
@@ -91877,7 +92049,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element in table
     scope</a> with the same tag name as the token, this is a
-    <a href=#parse-error>parse error</a>. Ignore the token.</p>
+    <a href=#parse-error>parse error</a>. Ignore the token.</p> <!-- fragment case? -->
 
     <p>Otherwise:</p>
 
@@ -91897,10 +92069,25 @@
    <dt>An end tag whose tag name is "table"</dt>
    <dd>
 
-    <p>Act as if an end tag with the tag name "tr" had been seen,
-    then, if that token wasn't ignored, reprocess the current
-    token.</p>
+    <!-- fake <tr> -->
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have a <code>tr</code> element in table
+    scope</a>, this is a
+    <a href=#parse-error>parse error</a>. Ignore the token.</p> <!-- fragment case? -->
 
+    <p>Otherwise:</p>
+
+    <p><a href=#clear-the-stack-back-to-a-table-row-context>Clear the stack back to a table row
+    context</a>. (See below.)</p>
+
+    <p>Pop the <a href=#current-node>current node</a> (which will be a
+    <code><a href=#the-tr-element>tr</a></code> element) from the <a href=#stack-of-open-elements>stack of open
+    elements</a>. Switch the <a href=#insertion-mode>insertion mode</a> to
+    "<a href=#parsing-main-intbody title="insertion mode: in table body">in table
+    body</a>".</p>
+    <!-- end of fake </tr> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
@@ -91911,9 +92098,24 @@
     scope</a> with the same tag name as the token, this is a
     <a href=#parse-error>parse error</a>. Ignore the token.</p>
 
-    <p>Otherwise, act as if an end tag with the tag name "tr" had
-    been seen, then reprocess the current token.</p>
+    <!-- fake <tr> -->
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have a <code>tr</code> element in table
+    scope</a>, ignore the token.</p> <!-- fragment case? -->
 
+    <p>Otherwise:</p>
+
+    <p><a href=#clear-the-stack-back-to-a-table-row-context>Clear the stack back to a table row
+    context</a>. (See below.)</p>
+
+    <p>Pop the <a href=#current-node>current node</a> (which will be a
+    <code><a href=#the-tr-element>tr</a></code> element) from the <a href=#stack-of-open-elements>stack of open
+    elements</a>. Switch the <a href=#insertion-mode>insertion mode</a> to
+    "<a href=#parsing-main-intbody title="insertion mode: in table body">in table
+    body</a>".</p>
+    <!-- end of fake </tr> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "body", "caption",
@@ -92015,15 +92217,21 @@
   </dl><p>Where the steps above say to <dfn id=close-the-cell>close the cell</dfn>, they
   mean to run the following algorithm:</p>
 
-  <ol><li><p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-table-scope title="has an element in table scope">has a <code>td</code>
-   element in table scope</a>, then act as if an end tag token
-   with the tag name "td" had been seen.</li>
+  <ol><!-- fake </td> or </th> --><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</li>
 
-   <li><p>Otherwise, the <a href=#stack-of-open-elements>stack of open elements</a> will
-   <a href=#has-an-element-in-table-scope title="has an element in table scope">have a
-   <code>th</code> element in table scope</a>; act as if an end
-   tag token with the tag name "th" had been seen.</li>
+   <li><p>If the <a href=#current-node>current node</a> is not now a <code><a href=#the-td-element>td</a></code> element or a <code><a href=#the-th-element>th</a></code>
+   element, then this is a <a href=#parse-error>parse error</a>.</li>
 
+   <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> stack until a <code><a href=#the-td-element>td</a></code>
+   element or a <code><a href=#the-th-element>th</a></code> element has been popped from the stack.</li>
+
+   <li><p><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker>Clear the list of active formatting elements up to the last marker</a>.</li>
+
+   <li><p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intr title="insertion mode: in row">in
+   row</a>".</li> <!-- current node here will be a <tr> normally; but could be <html> in the
+   fragment case, or <template> in the template case -->
+   <!-- end of fake </td> or </th> -->
+
   </ol><p class=note>The <a href=#stack-of-open-elements>stack of open elements</a> cannot have
   both a <code><a href=#the-td-element>td</a></code> and a <code><a href=#the-th-element>th</a></code> element <a href=#has-an-element-in-table-scope title="has an element in table scope">in table scope</a> at the
   same time, nor can it have neither when the <a href=#close-the-cell>close the
@@ -92064,9 +92272,11 @@
    <dt>A start tag whose tag name is "option"</dt>
    <dd>
 
+    <!-- fake </option> (maybe) -->
     <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-option-element>option</a></code>
-    element, act as if an end tag with the tag name "option" had
-    been seen.</p>
+    element, pop that node from the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
+    <!-- end of fake </option> -->
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
 
@@ -92075,13 +92285,17 @@
    <dt>A start tag whose tag name is "optgroup"</dt>
    <dd>
 
+    <!-- fake </option> (maybe) -->
     <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-option-element>option</a></code>
-    element, act as if an end tag with the tag name "option" had
-    been seen.</p>
+    element, pop that node from the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
+    <!-- end of fake </option> -->
 
-    <p>If the <a href=#current-node>current node</a> is an
-    <code><a href=#the-optgroup-element>optgroup</a></code> element, act as if an end tag with the
-    tag name "optgroup" had been seen.</p>
+    <!-- fake </optgroup> (maybe) -->
+    <p>If the <a href=#current-node>current node</a> is an <code><a href=#the-optgroup-element>optgroup</a></code>
+    element, pop that node from the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
+    <!-- end of fake </optgroup> -->
 
     <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
 
@@ -92090,11 +92304,13 @@
    <dt>An end tag whose tag name is "optgroup"</dt>
    <dd>
 
+    <!-- fake </option> (maybe) -->
     <p>First, if the <a href=#current-node>current node</a> is an
     <code><a href=#the-option-element>option</a></code> element, and the node immediately before
     it in the <a href=#stack-of-open-elements>stack of open elements</a> is an
-    <code><a href=#the-optgroup-element>optgroup</a></code> element, then act as if an end tag with
-    the tag name "option" had been seen.</p>
+    <code><a href=#the-optgroup-element>optgroup</a></code> element, then pop the <a href=#current-node>current node</a> from the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
+    <!-- end of fake </option> -->
 
     <p>If the <a href=#current-node>current node</a> is an
     <code><a href=#the-optgroup-element>optgroup</a></code> element, then pop that node from the
@@ -92134,9 +92350,18 @@
    <dt>A start tag whose tag name is "select"</dt>
    <dd>
 
-    <p><a href=#parse-error>Parse error</a>. Act as if the token had been
-    an end tag with the tag name "select" instead.</p>
+    <p><a href=#parse-error>Parse error</a>.</p>
 
+    <!-- fake </select> -->
+    <p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>
+    until a <code><a href=#the-select-element>select</a></code> element has been popped from the
+    stack.</p>
+
+    <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
+    <!-- end of fake </select> -->
+
+    <p class=note>It just gets treated like an end tag.</p>
+
    </dd>
 
    <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt>
@@ -92148,9 +92373,16 @@
     element in select scope</a>, ignore the token. (<a href=#fragment-case>fragment
     case</a>)</p>
 
-    <p>Otherwise, act as if an end tag with the tag name "select" had
-    been seen, and reprocess the token.</p>
+    <!-- fake </select> -->
+    <p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>
+    until a <code><a href=#the-select-element>select</a></code> element has been popped from the
+    stack.</p>
 
+    <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
+    <!-- end of fake </select> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>A start tag token whose tag name is "script"</dt>
@@ -92188,8 +92420,19 @@
   <dl class=switch><dt>A start tag whose tag name is one of: "caption", "table",
    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
    <dd>
-    <p><a href=#parse-error>Parse error</a>. Act as if an end tag with the tag
-    name "select" had been seen, and reprocess the token.</p>
+
+    <p><a href=#parse-error>Parse error</a>.</p>
+
+    <!-- fake </select> -->
+    <p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>
+    until a <code><a href=#the-select-element>select</a></code> element has been popped from the
+    stack.</p>
+
+    <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
+    <!-- end of fake </select> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "caption", "table",
@@ -92198,12 +92441,22 @@
 
     <p><a href=#parse-error>Parse error</a>.</p>
 
-    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> <a href=#has-an-element-in-table-scope>has an
+    <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an
     element in table scope</a> with the same tag name as that
-    of the token, then act as if an end tag with the tag name
-    "select" had been seen, and reprocess the token. Otherwise,
-    ignore the token.</p>
+    of the token, then ignore the token.</p>
 
+    <p>Otherwise:</p>
+
+    <!-- fake </select> -->
+    <p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>
+    until a <code><a href=#the-select-element>select</a></code> element has been popped from the
+    stack.</p>
+
+    <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
+    <!-- end of fake </select> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>Anything else</dt>
@@ -92323,9 +92576,20 @@
     <p>If there is no <code><a href=#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements>stack of open elements</a>, then
     <a href=#stop-parsing>stop parsing</a>. (<a href=#fragment-case>fragment case</a>)</p>
 
-    <p>Otherwise, this is a <a href=#parse-error>parse error</a>; act as if an end tag with the tag name
-    "template" had been seen and reprocess the current token.</p>
+    <p>Otherwise, this is a <a href=#parse-error>parse error</a>.</p>
 
+    <!-- fake </template> -->
+    <p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a> until a <code>templtae</code> element has been popped from the stack.</p>
+
+    <p><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker>Clear the list of active formatting elements up to the last marker</a>.</p>
+
+    <p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template insertion modes</a>.</p>
+
+    <p><a href=#reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
+    <!-- end of fake </template> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
   </dl><h6 id=parsing-main-afterbody><span class=secno>12.2.5.4.19 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6>

Modified: source
===================================================================
--- source	2013-06-28 22:44:17 UTC (rev 8000)
+++ source	2013-07-01 21:19:49 UTC (rev 8001)
@@ -100115,8 +100115,7 @@
    <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
    <dd>
 
-    <p>Act as if a start tag token with the tag name "head" and no
-    attributes had been seen, then reprocess the current token.</p>
+    <p>Act s described in the "anything else" entry below.</p>
 
    </dd>
 
@@ -100130,10 +100129,20 @@
    <dt>Anything else</dt>
    <dd>
 
-    <p>Act as if a start tag token with the tag name "head" and no
-    attributes had been seen, then reprocess the current
-    token.</p>
+    <!-- fake <head> -->
 
+    <p><span>Insert an HTML element</span> for a "head" start tag token with no attributes.</p>
+
+    <p>Set the <span><code title="">head</code> element pointer</span>
+    to the newly created <code>head</code> element.</p>
+
+    <p>Switch the <span>insertion mode</span> to "<span
+    title="insertion mode: in head">in head</span>".</p>
+
+    <!-- end of fake <head> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
   </dl>
@@ -100345,8 +100354,7 @@
      <li><p>Pop the <span>current template insertion mode</span> off the <span>stack of template
      insertion modes</span>.</p>
 
-     <li><p><span title="reset the insertion mode appropriately">Reset the
-     parser's insertion mode appropriately</span>.</p></li>
+     <li><p><span>Reset the insertion mode appropriately</span>.</p></li>
 
     </ol>
 
@@ -100363,9 +100371,17 @@
 
     <!-- can't get here with an EOF and a fragment case -->
 
-    <p>Act as if an end tag token with the tag name "head" had
-    been seen, and reprocess the current token.</p>
+    <!-- start of fake </head> -->
+    <p>Pop the <span>current node</span> (which will be the
+    <code>head</code> element) off the <span>stack of open
+    elements</span>.</p>
 
+    <p>Switch the <span>insertion mode</span> to "<span
+    title="insertion mode: after head">after head</span>".</p>
+    <!-- end of fake </head> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
   </dl>
@@ -100430,10 +100446,20 @@
 
     <!-- can't get here with an EOF and a fragment case -->
 
-    <p><span>Parse error</span>. Act as if an end tag with the tag
-    name "noscript" had been seen and reprocess the current
-    token.</p>
+    <p><span>Parse error</span>.</p>
 
+    <!-- fake </noscript> -->
+    <p>Pop the <span>current node</span> (which will be a
+    <code>noscript</code> element) from the <span>stack of open
+    elements</span>; the new <span>current node</span> will be a
+    <code>head</code> element.</p>
+
+    <p>Switch the <span>insertion mode</span> to "<span
+    title="insertion mode: in head">in head</span>".</p>
+    <!-- end fake </noscript> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
   </dl>
@@ -100528,10 +100554,16 @@
 
    <dt>Anything else</dt>
    <dd>
-    <p>Act as if a start tag token with the tag name "body" and no
-    attributes had been seen, then set the <span>frameset-ok
-    flag</span> back to "ok", and then reprocess the current
-    token.</p>
+
+    <!-- fake <body>, but without resetting frameset-ok -->
+    <p><span>Insert an HTML element</span> for a "body" start tag token with no attributes.</p>
+
+    <p>Switch the <span>insertion mode</span> to "<span
+    title="insertion mode: in body">in body</span>".</p>
+    <!-- end fake <body> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
   </dl>
@@ -100728,10 +100760,39 @@
    <dt>An end tag whose tag name is "html"</dt>
    <dd>
 
-    <p>Act as if an end tag with tag name "body" had been seen,
-    then, if that token wasn't ignored, reprocess the current
+    <!-- fake </body> -->
+    <p>If the <span>stack of open elements</span> does not <span
+    title="has an element in scope">have a <code>body</code> element
+    in scope</span>, this is a <span>parse error</span>; ignore the
     token.</p>
 
+    <!-- if we get here, the insertion mode here is forcibly "in
+    body". -->
+
+    <p>Otherwise, if there is a node in the <span>stack of open
+    elements</span> that is not either a <code>dd</code> element, a
+    <code>dt</code> element, an <code>li</code> element, an
+    <code>optgroup</code> element, an <code>option</code> element, a
+    <code>p</code> element, an <code>rp</code> element, an
+    <code>rt</code> element, a <code>tbody</code> element, a
+    <code>td</code> element, a <code>tfoot</code> element, a
+    <code>th</code> element, a <code>thead</code> element, a
+    <code>tr</code> element, the <code>body</code> element, or the
+    <code>html</code> element, then this is a <span>parse
+    error</span>.</p> <!-- (some of those are fragment cases, e.g. for
+    <tbody> you'd have hit the first paragraph since the <body>
+    wouldn't be in scope, unless it was a fragment case) -->
+
+    <!-- If we ever change the frameset-ok flag to an insertion mode,
+    then we'd have to somehow keep track of its state when we switch
+    to after-body. -->
+
+    <p>Switch the <span>insertion mode</span> to "<span
+    title="insertion mode: after body">after body</span>".</p>
+    <!-- end fake </body> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <!-- start tags for non-phrasing flow content elements -->
@@ -100750,8 +100811,7 @@
 
     <p>If the <span>stack of open elements</span> <span title="has an
     element in button scope">has a <code>p</code> element in button
-    scope</span>, then act as if an end tag with the tag name "p" had
-    been seen.</p>
+    scope</span>, then <span>close a <code>p</code> element</span>.</p>
 
     <p><span>Insert an HTML element</span> for the token.</p>
 
@@ -100764,8 +100824,7 @@
 
     <p>If the <span>stack of open elements</span> <span title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</span>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</span>, then <span>close a <code>p</code> element</span>.</p>
 
     <p>If the <span>current node</span> is an element whose tag name
     is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
@@ -100783,8 +100842,7 @@
 
     <p>If the <span>stack of open elements</span> <span title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</span>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</span>, then <span>close a <code>p</code> element</span>.</p>
 
     <p><span>Insert an HTML element</span> for the token.</p>
 
@@ -100812,8 +100870,7 @@
 
     <p>If the <span>stack of open elements</span> <span title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</span>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</span>, then <span>close a <code>p</code> element</span>.</p>
 
     <p><span>Insert an HTML element</span> for the token, and set the
     <span><code title="form">form</code> element pointer</span> to
@@ -100834,13 +100891,32 @@
      <li><p>Initialize <var title="">node</var> to be the <span>current
      node</span> (the bottommost node of the stack).</p></li>
 
-     <li><p><i>Loop</i>: If <var title="">node</var> is an
-     <code>li</code> element, then act as if an end tag with the tag
-     name "li" had been seen, then jump to the last step.</p></li>
+     <li>
 
+      <p><i>Loop</i>: If <var title="">node</var> is an <code>li</code> element, then run these
+      substeps:</p>
+
+      <ol>
+
+       <!-- fake </li> -->
+       <li><p><span>Generate implied end tags</span>, except for <code>li</code> elements.</p></li>
+
+       <li><p>If the <span>current node</span> is not an <code>li</code> element, then this is a
+       <span>parse error</span>.</p></li>
+
+       <li><p>Pop elements from the <span>stack of open elements</span> until an <code>li</code>
+       element has been popped from the stack.</p></li>
+       <!-- end of fake </li> -->
+
+       <li><p>Jump to the step labeled <i>done</i> below.</p></li>
+
+      </ol>
+
+     </li>
+
      <li><p>If <var title="">node</var> is in the <span>special</span>
      category, but is not an <code>address</code>, <code>div</code>,
-     or <code>p</code> element, then jump to the last step.</p></li>
+     or <code>p</code> element, then jump to the step labeled <i>done</i> below.</p></li>
      <!-- an element <foo> is in this list if the following markup:
 
          <!DOCTYPE html><body><ol><li><foo><li>
@@ -100853,20 +100929,12 @@
      entry in the <span>stack of open elements</span> and return to
      the step labeled <i>loop</i>.</p></li>
 
-     <li>
+     <li><p><i>Done</i>: If the <span>stack of open elements</span> <span title="has an element in
+     button scope">has a <code>p</code> element in button scope</span>, then <span>close a
+     <code>p</code> element</span>.</p></li>
 
-      <p>This is the last step.</p>
+     <li><p>Finally, <span>insert an HTML element</span> for the token.</p></li>
 
-      <p>If the <span>stack of open elements</span> <span title="has
-      an element in button scope">has a <code>p</code> element in button
-      scope</span>, then act as if an end tag with the tag name
-      "p" had been seen.</p>
-
-      <p>Finally, <span>insert an HTML element</span> for the
-      token.</p>
-
-     </li>
-
     </ol>
 
    </dd>
@@ -100884,14 +100952,54 @@
      <li><p>Initialize <var title="">node</var> to be the <span>current
      node</span> (the bottommost node of the stack).</p></li>
 
-     <li><p><i>Loop</i>: If <var title="">node</var> is a
-     <code>dd</code> or <code>dt</code> element, then act as if an end
-     tag with the same tag name as <var title="">node</var> had been
-     seen, then jump to the last step.</p></li>
+     <li>
 
+      <p><i>Loop</i>: If <var title="">node</var> is a <code>dd</code> element, then run these
+      substeps:</p>
+
+      <ol>
+
+       <!-- fake </dd> -->
+       <li><p><span>Generate implied end tags</span>, except for <code>dd</code> elements.</p></li>
+
+       <li><p>If the <span>current node</span> is not a <code>dd</code> element, then this is a
+       <span>parse error</span>.</p></li>
+
+       <li><p>Pop elements from the <span>stack of open elements</span> until a <code>dd</code>
+       element has been popped from the stack.</p></li>
+       <!-- end of fake </dd> -->
+
+       <li><p>Jump to the step labeled <i>done</i> below.</p></li>
+
+      </ol>
+
+     </li>
+
+     <li>
+
+      <p>If <var title="">node</var> is a <code>dt</code> element, then run these substeps:</p>
+
+      <ol>
+
+       <!-- fake </dt> -->
+       <li><p><span>Generate implied end tags</span>, except for <code>dt</code> elements.</p></li>
+
+       <li><p>If the <span>current node</span> is not a <code>dt</code> element, then this is a
+       <span>parse error</span>.</p></li>
+
+       <li><p>Pop elements from the <span>stack of open elements</span> until a <code>dt</code>
+       element has been popped from the stack.</p></li>
+       <!-- end of fake </dt> -->
+
+       <li><p>Jump to the step labeled <i>done</i> below.</p></li>
+
+      </ol>
+
+     </li>
+
      <li><p>If <var title="">node</var> is in the <span>special</span>
      category, but is not an <code>address</code>, <code>div</code>,
-     or <code>p</code> element, then jump to the last step.</p></li>
+     or <code>p</code> element, then jump to the step labeled <i>done</i> below.</p></li>
      <!-- an element <foo> is in this list if the following markup:
 
          <!DOCTYPE html><body><dl><dt><foo><dt>
@@ -100904,20 +101012,12 @@
      entry in the <span>stack of open elements</span> and return to
      the step labeled <i>loop</i>.</p></li>
 
-     <li>
+     <li><p><i>Done</i>: If the <span>stack of open elements</span> <span title="has an element in
+     button scope">has a <code>p</code> element in button scope</span>, then <span>close a
+     <code>p</code> element</span>.</p></li>
 
-      <p>This is the last step.</p>
+     <li><p>Finally, <span>insert an HTML element</span> for the token.</p></li>
 
-      <p>If the <span>stack of open elements</span> <span title="has
-      an element in button scope">has a <code>p</code> element in button
-      scope</span>, then act as if an end tag with the tag name
-      "p" had been seen.</p>
-
-      <p>Finally, <span>insert an HTML element</span> for the
-      token.</p>
-
-     </li>
-
     </ol>
 
    </dd>
@@ -100928,8 +101028,7 @@
 
     <p>If the <span>stack of open elements</span> <span title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</span>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</span>, then <span>close a <code>p</code> element</span>.</p>
 
     <p><span>Insert an HTML element</span> for the token.</p>
 
@@ -100946,21 +101045,34 @@
    <dt>A start tag whose tag name is "button"</dt>
    <dd>
 
-    <p>If the <span>stack of open elements</span> <span title="has
-    an element in scope">has a <code>button</code> element in
-    scope</span>, then this is a <span>parse error</span>;
-    act as if an end tag with the tag name "button" had been seen,
-    then reprocess the token.</p>
+    <ol>
 
-    <p>Otherwise:</p>
+     <li>
 
-    <p><span>Reconstruct the active formatting elements</span>, if
-    any.</p>
+      <p>If the <span>stack of open elements</span> <span title="has an element in scope">has a
+      <code>button</code> element in scope</span>, then run these substeps:</p>
 
-    <p><span>Insert an HTML element</span> for the token.</p>
+      <ol>
 
-    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
+       <li><p><span>Parse error</span>.</p></li>
 
+       <li><p><span>Generate implied end tags</span>.</p></li>
+
+       <li><p>Pop elements from the <span>stack of open elements</span> until a <code>button</code>
+       element has been popped from the stack.</p></li>
+
+      </ol>
+
+     </li>
+
+     <li><p><span>Reconstruct the active formatting elements</span>, if any.</p></li>
+
+     <li><p><span>Insert an HTML element</span> for the token.</p></li>
+
+     <li><p>Set the <span>frameset-ok flag</span> to "not ok".</p></li>
+
+    </ol>
+
    </dd>
 
    <!-- end tags for non-phrasing flow content elements (and button) -->
@@ -101033,29 +101145,13 @@
    <dt>An end tag whose tag name is "p"</dt>
    <dd>
 
-    <p>If the <span>stack of open elements</span> does not <span
-    title="has an element in button scope">have an element in button
-    scope</span> with the same tag name as that of the token, then this
-    is a <span>parse error</span>; act as if a start tag with the tag
-    name "p" had been seen, then reprocess the current token.</p>
+    <p>If the <span>stack of open elements</span> does not <span title="has an element in button
+    scope">have a <code>p</code> element in button scope</span>, then this is a <span>parse
+    error</span>; <span>insert an HTML element</span> for a "p" start tag token with no
+    attributes.</p>
 
-    <p>Otherwise, run these steps:</p>
+    <p><span>Close a <code>p</code> element</span>.</p>
 
-    <ol>
-
-     <li><p><span>Generate implied end tags</span>, except
-     for elements with the same tag name as the token.</p></li>
-
-     <li><p>If the <span>current node</span> is not an element with
-     the same tag name as that of the token, then this is a
-     <span>parse error</span>.</p></li>
-
-     <li><p>Pop elements from the <span>stack of open elements</span>
-     until an element with the same tag name as the token has been
-     popped from the stack.</p></li>
-
-    </ol>
-
    </dd>
 
    <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> -->
@@ -101455,8 +101551,8 @@
     <p>If the <code>Document</code> is <em>not</em> set to
     <span>quirks mode</span>, and the <span>stack of open
     elements</span> <span title="has an element in button scope">has a
-    <code>p</code> element in button scope</span>, then act as if an
-    end tag with the tag name "p" had been seen.</p> <!-- i hate
+    <code>p</code> element in button scope</span>, then <span>close a
+    <code>p</code> element</span>.</p> <!-- i hate
     myself (this quirk was basically caused by acid2; if i'd realised
     we could change the specs when i wrote acid2, we could have
     avoided having any parsing-mode quirks) -Hixie -->
@@ -101470,6 +101566,16 @@
 
    </dd>
 
+   <dt>An end tag whose tag name is "br"</dt>
+   <dd>
+
+    <p><span>Parse error</span>. Act as described in the next entry, as if this was a "br" start tag
+    token, rather than an end tag token.</p>
+
+   </dd>
+
+   <!-- do not insert things here, since the previous entry refers to the next entry -->
+
    <dt>A start tag whose tag name is one of: "area", "br", "embed",
    "img", "keygen", "wbr"</dt>
    <dd>
@@ -101527,8 +101633,7 @@
 
     <p>If the <span>stack of open elements</span> <span title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</span>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</span>, then <span>close a <code>p</code> element</span>.</p>
 
     <p><span>Insert an HTML element</span> for the token. Immediately
     pop the <span>current node</span> off the <span>stack of open
@@ -101565,42 +101670,62 @@
     included the /, they're not supposed to be including the tag at
     all! -->
 
-    <p>Act as if a start tag token with the tag name "form" had been seen.</p>
+    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
 
+    <!-- fake <form> -->
+    <p>If the <span>stack of open elements</span> <span title="has
+    an element in button scope">has a <code>p</code> element in button
+    scope</span>, then <span>close a <code>p</code> element</span>.</p>
+
+    <p><span>Insert an HTML element</span> for a "form" start tag token with no attributes, and set the
+    <span><code title="form">form</code> element pointer</span> to
+    point to the element created.</p>
+
     <p>If the token has an attribute called "action", set the
     <code title="attr-fs-action">action</code> attribute on the
     resulting <code>form</code> element to the value of the
     "action" attribute of the token.</p>
 
-    <p>Act as if a start tag token with the tag name "hr" had been
-    seen.</p>
+    <!-- fake <hr> -->
+    <p><span>Insert an HTML element</span> for an "hr" start tag token with no attributes.
+    Immediately pop the <span>current node</span> off the <span>stack of open elements</span>.</p>
 
-    <p>Act as if a start tag token with the tag name "label" had been
-    seen.</p>
+    <!-- fake <label> -->
+    <p><span>Reconstruct the active formatting elements</span>, if any.</p>
 
-    <p>Act as if a stream of character tokens had been seen (see below
-    for what they should say).</p>
+    <p><span>Insert an HTML element</span> for a "label" start tag token with no attributes.</p>
 
-    <p>Act as if a start tag token with the tag name "input" had been
-    seen, with all the attributes from the "isindex" token except
-    "name", "action", and "prompt". Set the <code
-    title="attr-fe-name">name</code> attribute of the resulting
-    <code>input</code> element to the value "<code
-    title="attr-fe-name-isindex">isindex</code>".</p>
+    <!-- fake text -->
+    <p><span title="insert a character">Insert characters</span> (see below for <span title="attr-isindex-prompt">what they should
+    say</span>).</p>
 
-    <p>Act as if a stream of character tokens had been seen (see
-    below for what they should say).</p>
+    <!-- fake <input> -->
+    <p><span>Insert an HTML element</span> for an "input" start tag token with all the attributes
+    from the "isindex" token except "name", "action", and "prompt", and with an attribute named
+    "name" with the value "isindex". (This creates an <code>input</code> element with the <code
+    title="attr-fe-name">name</code> attribute set to the magic balue "<code
+    title="attr-fe-name-isindex">isindex</code>".) Immediately pop the <span>current node</span> off
+    the <span>stack of open elements</span>.</p>
 
-    <p>Act as if an end tag token with the tag name "label" had been
-    seen.</p>
+    <!-- fake text -->
+    <p><span title="insert a character">Insert more characters</span> (see below for <span title="attr-isindex-prompt">what they
+    should say</span>).</p>
 
-    <p>Act as if a start tag token with the tag name "hr" had been
-    seen.</p>
+    <!-- fake </label> -->
+    <p>Pop the <span>current node</span> (which will be the <code>label</code> element created
+    earlier) off the <span>stack of open elements</span>.</p>
 
-    <p>Act as if an end tag token with the tag name "form" had been
-    seen.</p>
+    <!-- fake <hr> -->
+    <p><span>Insert an HTML element</span> for an "hr" start tag token with no attributes.
+    Immediately pop the <span>current node</span> off the <span>stack of open elements</span>.</p>
 
-    <p>If the token has an attribute with the name "prompt", then the
+    <!-- fake </form> -->
+    <p>Pop the <span>current node</span> (which will be the <code>form</code> element created
+    earlier) off the <span>stack of open elements</span>. Set the <span><code
+    title="form">form</code> element pointer</span> to null.</p>
+
+    <!-- explanation of text -->
+    <p><dfn title="attr-isindex-prompt"><strong>Prompt</strong></dfn>: If the token has an attribute with the name "prompt", then the
     first stream of characters must be the same string as given in
     that attribute, and the second stream of characters must be
     empty. Otherwise, the two streams of character tokens together
@@ -101648,8 +101773,7 @@
 
     <p>If the <span>stack of open elements</span> <span title="has
     an element in button scope">has a <code>p</code> element in button
-    scope</span>, then act as if an end tag with the tag name
-    "p" had been seen.</p>
+    scope</span>, then <span>close a <code>p</code> element</span>.</p>
 
     <p><span>Reconstruct the active formatting elements</span>, if
     any.</p>
@@ -101704,8 +101828,7 @@
    <dd>
 
     <p>If the <span>current node</span> is an <code>option</code>
-    element, then act as if an end tag with the tag name "option" had
-    been seen.</p>
+    element, then pop the <span>current node</span> off the <span>stack of open elements</span>.</p>
 
     <p><span>Reconstruct the active formatting elements</span>, if
     any.</p>
@@ -101749,12 +101872,6 @@
 
    </dd>
 
-   <dt>An end tag whose tag name is "br"</dt>
-   <dd>
-    <p><span>Parse error</span>. Act as if a start tag token with
-    the tag name "br" had been seen. Ignore the end tag token.</p>
-   </dd>
-
    <dt>A start tag whose tag name is "math"</dt>
    <dd>
 
@@ -101900,8 +102017,23 @@
 
   </dl>
 
+  <p>When the steps above say the user agent is to <dfn>close a <code>p</code> element</dfn>, it
+  means that the user agent must run the following steps:</p>
 
+  <ol> <!-- prereq: p in scope -->
 
+   <li><p><span>Generate implied end tags</span>, except for <code>p</code> elements.</p></li>
+
+   <li><p>If the <span>current node</span> is not a <code>p</code> element, then this is a
+   <span>parse error</span>.</p></li>
+
+   <li><p>Pop elements from the <span>stack of open elements</span> until a <code>p</code> element
+   has been popped from the stack.</p></li>
+
+  </ol>
+
+
+
   <h6 id="parsing-main-incdata">The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h6>
 
   <p>When the user agent is to apply the rules for the "<span title="insertion mode: text">text</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
@@ -102127,8 +102259,19 @@
 
    <dt>A start tag whose tag name is "col"</dt>
    <dd>
-    <p>Act as if a start tag token with the tag name "colgroup"
-    had been seen, then reprocess the current token.</p>
+
+    <!-- fake <colgroup> -->
+    <p><span>Clear the stack back to a table context</span>. (See
+    below.)</p>
+
+    <p><span>Insert an HTML element</span> for a "colgroup" start tag token with no attributes, then
+    switch the <span>insertion mode</span> to "<span
+    title="insertion mode: in column group">in column
+    group</span>".</p>
+    <!-- end of fake <colgroup> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
    <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt>
@@ -102146,17 +102289,41 @@
 
    <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt>
    <dd>
-    <p>Act as if a start tag token with the tag name "tbody" had
-    been seen, then reprocess the current token.</p>
+
+    <!-- fake <colgroup> -->
+    <p><span>Clear the stack back to a table context</span>. (See
+    below.)</p>
+
+    <p><span>Insert an HTML element</span> for a "tbody" start tag token with no attributes, then
+    switch the <span>insertion mode</span> to "<span
+    title="insertion mode: in table body">in table
+    body</span>".</p>
+    <!-- end of fake <colgroup> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
    <dt>A start tag whose tag name is "table"</dt>
    <dd>
 
-    <p><span>Parse error</span>. Act as if an end tag token with
-    the tag name "table" had been seen, then, if that token wasn't
-    ignored, reprocess the current token.</p>
+    <p><span>Parse error</span>.</p>
 
+    <!-- fake </table> -->
+    <p>If the <span>stack of open elements</span> does not <span
+    title="has an element in table scope">have an element in table
+    scope</span> with the same tag name as the token, ignore the token.</p> <!-- fragment case? -->
+
+    <p>Otherwise:</p>
+
+    <p>Pop elements from this stack until a <code>table</code>
+    element has been popped from the stack.</p>
+
+    <p><span>Reset the insertion mode appropriately</span>.</p>
+    <!-- end of fake </table> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is "table"</dt>
@@ -102165,7 +102332,7 @@
     <p>If the <span>stack of open elements</span> does not <span
     title="has an element in table scope">have an element in table
     scope</span> with the same tag name as the token, this is a
-    <span>parse error</span>. Ignore the token.</p>
+    <span>parse error</span>. Ignore the token.</p> <!-- fragment case? -->
 
     <p>Otherwise:</p>
 
@@ -102377,13 +102544,28 @@
    <dt>An end tag whose tag name is "table"</dt>
    <dd>
 
-    <p><span>Parse error</span>. Act as if an end tag with the tag
-    name "caption" had been seen, then, if that token wasn't
-    ignored, reprocess the current token.</p>
+    <p><span>Parse error</span>.</p>
 
-    <p class="note">The fake end tag token here can only be
-    ignored in the <span>fragment case</span>.</p>
+    <!-- fake </caption> -->
+    <p>If the <span>stack of open elements</span> does not <span
+    title="has an element in table scope">have a <code>caption</code> element in table
+    scope</span>, ignore the token. (<span>fragment
+    case</span>)</p>
 
+    <p>Otherwise:</p>
+
+    <p>Pop elements from this stack until a <code>caption</code>
+    element has been popped from the stack.</p>
+
+    <p><span>Clear the list of active formatting elements up to
+    the last marker</span>.</p>
+
+    <p>Switch the <span>insertion mode</span> to "<span
+    title="insertion mode: in table">in table</span>".</p>
+    <!-- end of fake </caption> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "body", "col",
@@ -102484,10 +102666,19 @@
    <dt>Anything else</dt>
    <dd>
 
-    <p>Act as if an end tag with the tag name "colgroup" had been
-    seen, and then, if that token wasn't ignored, reprocess the
-    current token.</p>
+    <!-- fake </colgroup> -->
+    <p>If the <span>current node</span> is not a <code>colgroup</code> element, then this is a <span>parse
+    error</span>; ignore the token.</p> <!-- e.g. colgroup fragment case, or <template><col></colgroup> -->
 
+    <p>Otherwise, pop the <span>current node</span> from the <span>stack of open
+    elements</span>.</p>
+
+    <p>Switch the <span>insertion mode</span> to
+    "<span title="insertion mode: in table">in table</span>".</p>
+    <!-- end of fake </colgroup> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
   </dl>
@@ -102513,9 +102704,20 @@
 
    <dt>A start tag whose tag name is one of: "th", "td"</dt>
    <dd>
-    <p><span>Parse error</span>. Act as if a start tag with
-    the tag name "tr" had been seen, then reprocess the current
-    token.</p>
+
+    <p><span>Parse error</span>.</p>
+
+    <!-- fake </tr> -->
+    <p><span>Clear the stack back to a table body
+    context</span>. (See below.)</p>
+
+    <p><span>Insert an HTML element</span> for a "tr" start tag token with no attributes, then switch
+    the <span>insertion mode</span> to "<span title="insertion mode:
+    in row">in row</span>".</p>
+    <!-- end of fake </tr> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
@@ -102554,10 +102756,14 @@
     <p><span>Clear the stack back to a table body
     context</span>. (See below.)</p>
 
-    <p>Act as if an end tag with the same tag name as the
-    <span>current node</span> ("tbody", "tfoot", or "thead") had
-    been seen, then reprocess the current token.</p>
+    <!-- fake </tbody>, </tfoot>, or </thead>, whatever is the current node -->
+    <p>Pop the <span>current node</span> from the <span>stack of
+    open elements</span>. Switch the <span>insertion mode</span>
+    to "<span title="insertion mode: in table">in table</span>".</p>
+    <!-- end of fake </tbody>, </tfoot>, or </thead>, whatever was the current node -->
 
+    <p>Reprocess the current token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "body", "caption",
@@ -102614,7 +102820,7 @@
     <p>If the <span>stack of open elements</span> does not <span
     title="has an element in table scope">have an element in table
     scope</span> with the same tag name as the token, this is a
-    <span>parse error</span>. Ignore the token.</p>
+    <span>parse error</span>. Ignore the token.</p> <!-- fragment case? -->
 
     <p>Otherwise:</p>
 
@@ -102634,10 +102840,26 @@
    <dt>An end tag whose tag name is "table"</dt>
    <dd>
 
-    <p>Act as if an end tag with the tag name "tr" had been seen,
-    then, if that token wasn't ignored, reprocess the current
-    token.</p>
+    <!-- fake <tr> -->
+    <p>If the <span>stack of open elements</span> does not <span
+    title="has an element in table scope">have a <code>tr</code> element in table
+    scope</span>, this is a
+    <span>parse error</span>. Ignore the token.</p> <!-- fragment case? -->
 
+    <p>Otherwise:</p>
+
+    <p><span>Clear the stack back to a table row
+    context</span>. (See below.)</p>
+
+    <p>Pop the <span>current node</span> (which will be a
+    <code>tr</code> element) from the <span>stack of open
+    elements</span>. Switch the <span>insertion mode</span> to
+    "<span title="insertion mode: in table body">in table
+    body</span>".</p>
+    <!-- end of fake </tr> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
@@ -102649,9 +102871,25 @@
     scope</span> with the same tag name as the token, this is a
     <span>parse error</span>. Ignore the token.</p>
 
-    <p>Otherwise, act as if an end tag with the tag name "tr" had
-    been seen, then reprocess the current token.</p>
+    <!-- fake <tr> -->
+    <p>If the <span>stack of open elements</span> does not <span
+    title="has an element in table scope">have a <code>tr</code> element in table
+    scope</span>, ignore the token.</p> <!-- fragment case? -->
 
+    <p>Otherwise:</p>
+
+    <p><span>Clear the stack back to a table row
+    context</span>. (See below.)</p>
+
+    <p>Pop the <span>current node</span> (which will be a
+    <code>tr</code> element) from the <span>stack of open
+    elements</span>. Switch the <span>insertion mode</span> to
+    "<span title="insertion mode: in table body">in table
+    body</span>".</p>
+    <!-- end of fake </tr> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "body", "caption",
@@ -102766,16 +103004,22 @@
 
   <ol>
 
-   <li><p>If the <span>stack of open elements</span> <span
-   title="has an element in table scope">has a <code>td</code>
-   element in table scope</span>, then act as if an end tag token
-   with the tag name "td" had been seen.</p></li>
+   <!-- fake </td> or </th> -->
+   <li><p><span>Generate implied end tags</span>.</p></li>
 
-   <li><p>Otherwise, the <span>stack of open elements</span> will
-   <span title="has an element in table scope">have a
-   <code>th</code> element in table scope</span>; act as if an end
-   tag token with the tag name "th" had been seen.</p></li>
+   <li><p>If the <span>current node</span> is not now a <code>td</code> element or a <code>th</code>
+   element, then this is a <span>parse error</span>.</p></li>
 
+   <li><p>Pop elements from the <span>stack of open elements</span> stack until a <code>td</code>
+   element or a <code>th</code> element has been popped from the stack.</p></li>
+
+   <li><p><span>Clear the list of active formatting elements up to the last marker</span>.</p></li>
+
+   <li><p>Switch the <span>insertion mode</span> to "<span title="insertion mode: in row">in
+   row</span>".</p></li> <!-- current node here will be a <tr> normally; but could be <html> in the
+   fragment case, or <template> in the template case -->
+   <!-- end of fake </td> or </th> -->
+
   </ol>
 
   <p class="note">The <span>stack of open elements</span> cannot have
@@ -102822,9 +103066,11 @@
    <dt>A start tag whose tag name is "option"</dt>
    <dd>
 
+    <!-- fake </option> (maybe) -->
     <p>If the <span>current node</span> is an <code>option</code>
-    element, act as if an end tag with the tag name "option" had
-    been seen.</p>
+    element, pop that node from the <span>stack of open
+    elements</span>.</p>
+    <!-- end of fake </option> -->
 
     <p><span>Insert an HTML element</span> for the token.</p>
 
@@ -102833,13 +103079,17 @@
    <dt>A start tag whose tag name is "optgroup"</dt>
    <dd>
 
+    <!-- fake </option> (maybe) -->
     <p>If the <span>current node</span> is an <code>option</code>
-    element, act as if an end tag with the tag name "option" had
-    been seen.</p>
+    element, pop that node from the <span>stack of open
+    elements</span>.</p>
+    <!-- end of fake </option> -->
 
-    <p>If the <span>current node</span> is an
-    <code>optgroup</code> element, act as if an end tag with the
-    tag name "optgroup" had been seen.</p>
+    <!-- fake </optgroup> (maybe) -->
+    <p>If the <span>current node</span> is an <code>optgroup</code>
+    element, pop that node from the <span>stack of open
+    elements</span>.</p>
+    <!-- end of fake </optgroup> -->
 
     <p><span>Insert an HTML element</span> for the token.</p>
 
@@ -102848,11 +103098,13 @@
    <dt>An end tag whose tag name is "optgroup"</dt>
    <dd>
 
+    <!-- fake </option> (maybe) -->
     <p>First, if the <span>current node</span> is an
     <code>option</code> element, and the node immediately before
     it in the <span>stack of open elements</span> is an
-    <code>optgroup</code> element, then act as if an end tag with
-    the tag name "option" had been seen.</p>
+    <code>optgroup</code> element, then pop the <span>current node</span> from the <span>stack of open
+    elements</span>.</p>
+    <!-- end of fake </option> -->
 
     <p>If the <span>current node</span> is an
     <code>optgroup</code> element, then pop that node from the
@@ -102893,9 +103145,18 @@
    <dt>A start tag whose tag name is "select"</dt>
    <dd>
 
-    <p><span>Parse error</span>. Act as if the token had been
-    an end tag with the tag name "select" instead.</p>
+    <p><span>Parse error</span>.</p>
 
+    <!-- fake </select> -->
+    <p>Pop elements from the <span>stack of open elements</span>
+    until a <code>select</code> element has been popped from the
+    stack.</p>
+
+    <p><span>Reset the insertion mode appropriately</span>.</p>
+    <!-- end of fake </select> -->
+
+    <p class="note">It just gets treated like an end tag.</p>
+
    </dd>
 
    <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt>
@@ -102908,9 +103169,16 @@
     element in select scope</span>, ignore the token. (<span>fragment
     case</span>)</p>
 
-    <p>Otherwise, act as if an end tag with the tag name "select" had
-    been seen, and reprocess the token.</p>
+    <!-- fake </select> -->
+    <p>Pop elements from the <span>stack of open elements</span>
+    until a <code>select</code> element has been popped from the
+    stack.</p>
 
+    <p><span>Reset the insertion mode appropriately</span>.</p>
+    <!-- end of fake </select> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>A start tag token whose tag name is "script"</dt>
@@ -102956,8 +103224,19 @@
    <dt>A start tag whose tag name is one of: "caption", "table",
    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
    <dd>
-    <p><span>Parse error</span>. Act as if an end tag with the tag
-    name "select" had been seen, and reprocess the token.</p>
+
+    <p><span>Parse error</span>.</p>
+
+    <!-- fake </select> -->
+    <p>Pop elements from the <span>stack of open elements</span>
+    until a <code>select</code> element has been popped from the
+    stack.</p>
+
+    <p><span>Reset the insertion mode appropriately</span>.</p>
+    <!-- end of fake </select> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is one of: "caption", "table",
@@ -102966,12 +103245,22 @@
 
     <p><span>Parse error</span>.</p>
 
-    <p>If the <span>stack of open elements</span> <span>has an
+    <p>If the <span>stack of open elements</span> does not <span title="has an element in table scope">have an
     element in table scope</span> with the same tag name as that
-    of the token, then act as if an end tag with the tag name
-    "select" had been seen, and reprocess the token. Otherwise,
-    ignore the token.</p>
+    of the token, then ignore the token.</p>
 
+    <p>Otherwise:</p>
+
+    <!-- fake </select> -->
+    <p>Pop elements from the <span>stack of open elements</span>
+    until a <code>select</code> element has been popped from the
+    stack.</p>
+
+    <p><span>Reset the insertion mode appropriately</span>.</p>
+    <!-- end of fake </select> -->
+
+    <p>Reprocess the token.</p>
+
    </dd>
 
    <dt>Anything else</dt>
@@ -103110,9 +103399,20 @@
     <p>If there is no <code>template</code> element on the <span>stack of open elements</span>, then
     <span>stop parsing</span>. (<span>fragment case</span>)</p>
 
-    <p>Otherwise, this is a <span>parse error</span>; act as if an end tag with the tag name
-    "template" had been seen and reprocess the current token.</p>
+    <p>Otherwise, this is a <span>parse error</span>.</p>
 
+    <!-- fake </template> -->
+    <p>Pop elements from the <span>stack of open elements</span> until a <code>templtae</code> element has been popped from the stack.</p>
+
+    <p><span>Clear the list of active formatting elements up to the last marker</span>.</p>
+
+    <p>Pop the <span>current template insertion mode</span> off the <span>stack of template insertion modes</span>.</p>
+
+    <p><span>Reset the insertion mode appropriately</span>.</p>
+    <!-- end of fake </template> -->
+
+    <p>Reprocess the current token.</p>
+
    </dd>
 
   </dl>




More information about the Commit-Watchers mailing list