[html5] r5920 - [giow] (1) Change how MathML and SVG are parsed in text/html: use a three-level [...]

whatwg at whatwg.org whatwg at whatwg.org
Mon Feb 28 15:56:24 PST 2011


Author: ianh
Date: 2011-02-28 15:56:22 -0800 (Mon, 28 Feb 2011)
New Revision: 5920

Modified:
   complete.html
   index
   source
Log:
[giow] (1) Change how MathML and SVG are parsed in text/html: use a three-level tree constructor design instead of the two-level design we had before.
Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=11393

Modified: complete.html
===================================================================
--- complete.html	2011-02-27 00:03:26 UTC (rev 5919)
+++ complete.html	2011-02-28 23:56:22 UTC (rev 5920)
@@ -239,7 +239,7 @@
 
   <header class=head id=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
    <hgroup><h1>Web Applications 1.0</h1>
-    <h2 class="no-num no-toc">Living Standard — Last Updated 27 February 2011</h2>
+    <h2 class="no-num no-toc">Living Standard — Last Updated 28 February 2011</h2>
    </hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
    <p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
    <!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
@@ -1222,29 +1222,31 @@
        <li><a href=#creating-and-inserting-elements><span class=secno>12.2.5.1 </span>Creating and inserting elements</a></li>
        <li><a href=#closing-elements-that-have-implied-end-tags><span class=secno>12.2.5.2 </span>Closing elements that have implied end tags</a></li>
        <li><a href=#foster-parenting><span class=secno>12.2.5.3 </span>Foster parenting</a></li>
-       <li><a href=#the-initial-insertion-mode><span class=secno>12.2.5.4 </span>The "initial" insertion mode</a></li>
-       <li><a href=#the-before-html-insertion-mode><span class=secno>12.2.5.5 </span>The "before html" insertion mode</a></li>
-       <li><a href=#the-before-head-insertion-mode><span class=secno>12.2.5.6 </span>The "before head" insertion mode</a></li>
-       <li><a href=#parsing-main-inhead><span class=secno>12.2.5.7 </span>The "in head" insertion mode</a></li>
-       <li><a href=#parsing-main-inheadnoscript><span class=secno>12.2.5.8 </span>The "in head noscript" insertion mode</a></li>
-       <li><a href=#the-after-head-insertion-mode><span class=secno>12.2.5.9 </span>The "after head" insertion mode</a></li>
-       <li><a href=#parsing-main-inbody><span class=secno>12.2.5.10 </span>The "in body" insertion mode</a></li>
-       <li><a href=#parsing-main-incdata><span class=secno>12.2.5.11 </span>The "text" insertion mode</a></li>
-       <li><a href=#parsing-main-intable><span class=secno>12.2.5.12 </span>The "in table" insertion mode</a></li>
-       <li><a href=#parsing-main-intabletext><span class=secno>12.2.5.13 </span>The "in table text" insertion mode</a></li>
-       <li><a href=#parsing-main-incaption><span class=secno>12.2.5.14 </span>The "in caption" insertion mode</a></li>
-       <li><a href=#parsing-main-incolgroup><span class=secno>12.2.5.15 </span>The "in column group" insertion mode</a></li>
-       <li><a href=#parsing-main-intbody><span class=secno>12.2.5.16 </span>The "in table body" insertion mode</a></li>
-       <li><a href=#parsing-main-intr><span class=secno>12.2.5.17 </span>The "in row" insertion mode</a></li>
-       <li><a href=#parsing-main-intd><span class=secno>12.2.5.18 </span>The "in cell" insertion mode</a></li>
-       <li><a href=#parsing-main-inselect><span class=secno>12.2.5.19 </span>The "in select" insertion mode</a></li>
-       <li><a href=#parsing-main-inselectintable><span class=secno>12.2.5.20 </span>The "in select in table" insertion mode</a></li>
-       <li><a href=#parsing-main-inforeign><span class=secno>12.2.5.21 </span>The "in foreign content" insertion mode</a></li>
-       <li><a href=#parsing-main-afterbody><span class=secno>12.2.5.22 </span>The "after body" insertion mode</a></li>
-       <li><a href=#parsing-main-inframeset><span class=secno>12.2.5.23 </span>The "in frameset" insertion mode</a></li>
-       <li><a href=#parsing-main-afterframeset><span class=secno>12.2.5.24 </span>The "after frameset" insertion mode</a></li>
-       <li><a href=#the-after-after-body-insertion-mode><span class=secno>12.2.5.25 </span>The "after after body" insertion mode</a></li>
-       <li><a href=#the-after-after-frameset-insertion-mode><span class=secno>12.2.5.26 </span>The "after after frameset" insertion mode</a></ol></li>
+       <li><a href=#parsing-main-inhtml><span class=secno>12.2.5.4 </span>The rules for parsing tokens in HTML content</a>
+        <ol>
+         <li><a href=#the-initial-insertion-mode><span class=secno>12.2.5.4.1 </span>The "initial" insertion mode</a></li>
+         <li><a href=#the-before-html-insertion-mode><span class=secno>12.2.5.4.2 </span>The "before html" insertion mode</a></li>
+         <li><a href=#the-before-head-insertion-mode><span class=secno>12.2.5.4.3 </span>The "before head" insertion mode</a></li>
+         <li><a href=#parsing-main-inhead><span class=secno>12.2.5.4.4 </span>The "in head" insertion mode</a></li>
+         <li><a href=#parsing-main-inheadnoscript><span class=secno>12.2.5.4.5 </span>The "in head noscript" insertion mode</a></li>
+         <li><a href=#the-after-head-insertion-mode><span class=secno>12.2.5.4.6 </span>The "after head" insertion mode</a></li>
+         <li><a href=#parsing-main-inbody><span class=secno>12.2.5.4.7 </span>The "in body" insertion mode</a></li>
+         <li><a href=#parsing-main-incdata><span class=secno>12.2.5.4.8 </span>The "text" insertion mode</a></li>
+         <li><a href=#parsing-main-intable><span class=secno>12.2.5.4.9 </span>The "in table" insertion mode</a></li>
+         <li><a href=#parsing-main-intabletext><span class=secno>12.2.5.4.10 </span>The "in table text" insertion mode</a></li>
+         <li><a href=#parsing-main-incaption><span class=secno>12.2.5.4.11 </span>The "in caption" insertion mode</a></li>
+         <li><a href=#parsing-main-incolgroup><span class=secno>12.2.5.4.12 </span>The "in column group" insertion mode</a></li>
+         <li><a href=#parsing-main-intbody><span class=secno>12.2.5.4.13 </span>The "in table body" insertion mode</a></li>
+         <li><a href=#parsing-main-intr><span class=secno>12.2.5.4.14 </span>The "in row" insertion mode</a></li>
+         <li><a href=#parsing-main-intd><span class=secno>12.2.5.4.15 </span>The "in cell" insertion mode</a></li>
+         <li><a href=#parsing-main-inselect><span class=secno>12.2.5.4.16 </span>The "in select" insertion mode</a></li>
+         <li><a href=#parsing-main-inselectintable><span class=secno>12.2.5.4.17 </span>The "in select in table" insertion mode</a></li>
+         <li><a href=#parsing-main-afterbody><span class=secno>12.2.5.4.18 </span>The "after body" insertion mode</a></li>
+         <li><a href=#parsing-main-inframeset><span class=secno>12.2.5.4.19 </span>The "in frameset" insertion mode</a></li>
+         <li><a href=#parsing-main-afterframeset><span class=secno>12.2.5.4.20 </span>The "after frameset" insertion mode</a></li>
+         <li><a href=#the-after-after-body-insertion-mode><span class=secno>12.2.5.4.21 </span>The "after after body" insertion mode</a></li>
+         <li><a href=#the-after-after-frameset-insertion-mode><span class=secno>12.2.5.4.22 </span>The "after after frameset" insertion mode</a></ol></li>
+       <li><a href=#parsing-main-inforeign><span class=secno>12.2.5.5 </span>The rules for parsing tokens in foreign content</a></ol></li>
      <li><a href=#the-end><span class=secno>12.2.6 </span>The end</a></li>
      <li><a href=#coercing-an-html-dom-into-an-infoset><span class=secno>12.2.7 </span>Coercing an HTML DOM into an infoset</a></li>
      <li><a href=#an-introduction-to-error-handling-and-strange-cases-in-the-parser><span class=secno>12.2.8 </span>An introduction to error handling and strange cases in the parser</a>
@@ -77982,12 +77984,16 @@
   "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before html</a>",
   "<a href=#the-before-head-insertion-mode title="insertion mode: before head">before head</a>",
   "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>", "<a href=#parsing-main-inheadnoscript title="insertion mode: in head noscript">in head noscript</a>",
-  "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</a>", "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>", "<a href=#parsing-main-incdata title="insertion mode: text">text</a>",
-  "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>", "<a href=#parsing-main-intabletext title="insertion mode: in table text">in table text</a>", "<a href=#parsing-main-incaption title="insertion mode: in caption">in caption</a>", "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</a>",
-  "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>",
-  "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>", "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>", "<a href=#parsing-main-inselect title="insertion mode: in select">in select</a>", "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in select in
-  table</a>", "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in
-  foreign content</a>", "<a href=#parsing-main-afterbody title="insertion mode: after
+  "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</a>", "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>", "<a href=#parsing-main-incdata title="insertion mode: text">text</a>", "<a href=#parsing-main-intable title="insertion
+  mode: in table">in table</a>", "<a href=#parsing-main-intabletext title="insertion mode: in
+  table text">in table text</a>", "<a href=#parsing-main-incaption title="insertion mode: in
+  caption">in caption</a>", "<a href=#parsing-main-incolgroup title="insertion mode: in column
+  group">in column group</a>", "<a href=#parsing-main-intbody title="insertion mode: in
+  table body">in table body</a>", "<a href=#parsing-main-intr title="insertion mode: in
+  row">in row</a>", "<a href=#parsing-main-intd title="insertion mode: in cell">in
+  cell</a>", "<a href=#parsing-main-inselect title="insertion mode: in select">in
+  select</a>", "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in
+  select in table</a>", "<a href=#parsing-main-afterbody title="insertion mode: after
   body">after body</a>", "<a href=#parsing-main-inframeset title="insertion mode: in
   frameset">in frameset</a>", "<a href=#parsing-main-afterframeset title="insertion mode: after
   frameset">after frameset</a>", "<a href=#the-after-after-body-insertion-mode title="insertion mode:
@@ -78092,12 +78098,6 @@
    non-null when we're going through these steps, we'll need to
    uncomment out the commented-out bits -->
 
-   <li>If <var title="">node</var> is an element from the <a href=#mathml-namespace>MathML
-   namespace</a> or the <a href=#svg-namespace>SVG namespace</a>, then switch the
-   <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inforeign title="insertion mode: in
-   foreign content">in foreign content</a>" and abort these
-   steps.</li>
-
    <li>If <var title="">last</var> is true, then switch the
    <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in
    body">in body</a>" and abort these steps. (<a href=#fragment-case>fragment
@@ -79705,11 +79705,10 @@
   case-insensitive</a> match for the word "DOCTYPE", then consume
   those characters and switch to the <a href=#doctype-state>DOCTYPE state</a>.</p>
 
-  <p>Otherwise, if the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign
-  content</a>" and the <a href=#current-node>current node</a> is not an element
-  in the <a href=#html-namespace-0>HTML namespace</a> and the next seven characters are
-  an <a href=#case-sensitive>case-sensitive</a> match for the string "[CDATA[" (the
-  five uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
+  <p>Otherwise, if the <a href=#current-node>current node</a> is not an element in
+  the <a href=#html-namespace-0>HTML namespace</a> and the next seven characters are an
+  <a href=#case-sensitive>case-sensitive</a> match for the string "[CDATA[" (the five
+  uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
   character before and after), then consume those characters and
   switch to the <a href=#cdata-section-state>CDATA section state</a>.</p>
 
@@ -80611,11 +80610,44 @@
   has to render the <code><a href=#document>Document</a></code> so that it is available to
   the user, or when it has to begin accepting user input.</p>
 
-  <p>As each token is emitted from the tokenizer, the user agent must
-  process the token according to the rules given in the section
-  corresponding to the current <a href=#insertion-mode>insertion mode</a>.</p>
+  <hr><p>As each token is emitted from the tokenizer, the user agent must
+  follow the appropriate steps from the following list:</p>
 
-  <p>When the steps below require the UA to <dfn id=insert-a-character>insert a
+  <dl class=switch><dt>If there is no <a href=#current-node>current node</a></dt>
+   <dt>If the <a href=#current-node>current node</a> is an element in the <a href=#html-namespace-0>HTML namespace</a></dt>
+   <dt>If the <a href=#current-node>current node</a> is a <a href=#mathml-text-integration-point>MathML text integration point</a> and the token is a start tag whose tag name is neither "mglyph" nor "malignmark"</dt>
+   <dt>If the <a href=#current-node>current node</a> is an <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> and the token is a start tag whose tag name is "svg"</dt>
+   <dt>If the <a href=#current-node>current node</a> is an <a href=#html-integration-point>HTML integration point</a> and the token is a start tag</dt>
+   <dt>If the <a href=#current-node>current node</a> is an <a href=#html-integration-point>HTML integration point</a> and the token is a character token</dt>
+   <dt>If the token is an end-of-file token</dt>
+
+   <dd>Process the token according to the rules given in the section
+   corresponding to the current <a href=#insertion-mode>insertion mode</a> in HTML
+   content.</dd>
+
+   <dt>Otherwise</dt>
+
+   <dd>Process the token according to the rules given in the section
+   for parsing tokens <a href=#parsing-main-inforeign title="insertion mode: in foreign
+   content">in foreign content</a>.</dd>
+
+  </dl><p>The <a href=#current-node>current node</a> is a <dfn id=mathml-text-integration-point>MathML text
+  integration point</dfn> if it is one of the following elements:</p>
+
+  <ul class=brief><li>An <code title="">mi</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
+   <li>An <code title="">mo</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
+   <li>An <code title="">mn</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
+   <li>An <code title="">ms</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
+   <li>An <code title="">mtext</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
+  </ul><p>The <a href=#current-node>current node</a> is an <dfn id=html-integration-point>HTML
+  integration point</dfn> if it is one of the following elements:</p>
+
+  <ul class=brief><li>An <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> whose start tag token had an attribute with the name "encoding" whose value was an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">text/html</code>"</li>
+   <li>An <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> whose start tag token had an attribute with the name "encoding" whose value was an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">application/xhtml+xml</code>"</li>
+   <li>A <code title="">foreignObject</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
+   <li>A <code title="">desc</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
+   <li>A <code title="">title</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
+  </ul><hr><p>When the steps below require the UA to <dfn id=insert-a-character>insert a
   character</dfn> into a node, if that node has a child immediately
   before where the character is to be inserted, and that child is a
   <code><a href=#text>Text</a></code> node, then the character must be appended to that
@@ -80907,11 +80939,13 @@
 
 
 
-  <h5 id=the-initial-insertion-mode><span class=secno>12.2.5.4 </span>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h5>
+  <h5 id=parsing-main-inhtml><span class=secno>12.2.5.4 </span>The rules for parsing tokens in HTML content</h5>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#the-initial-insertion-mode title="insertion
-  mode: initial">initial</a>", tokens must be handled as follows:</p>
 
+  <h6 id=the-initial-insertion-mode><span class=secno>12.2.5.4.1 </span>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h6>
+
+  <p>When the user agent is to apply the rules for the "<a href=#the-initial-insertion-mode title="insertion mode: initial">initial</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 that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
@@ -81101,10 +81135,9 @@
 
    </dd>
 
-  </dl><h5 id=the-before-html-insertion-mode><span class=secno>12.2.5.5 </span>The "<dfn title="insertion mode: before html">before html</dfn>" insertion mode</h5>
+  </dl><h6 id=the-before-html-insertion-mode><span class=secno>12.2.5.4.2 </span>The "<dfn title="insertion mode: before html">before html</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#the-before-html-insertion-mode title="insertion
-  mode: before html">before html</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before html</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A DOCTYPE token</dt>
    <dd>
@@ -81185,10 +81218,9 @@
   as described in the next section.</p>
 
 
-  <h5 id=the-before-head-insertion-mode><span class=secno>12.2.5.6 </span>The "<dfn title="insertion mode: before head">before head</dfn>" insertion mode</h5>
+  <h6 id=the-before-head-insertion-mode><span class=secno>12.2.5.4.3 </span>The "<dfn title="insertion mode: before head">before head</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#the-before-head-insertion-mode title="insertion
-  mode: before head">before head</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#the-before-head-insertion-mode title="insertion mode: before head">before head</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 that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
@@ -81251,10 +81283,9 @@
 
    </dd>
 
-  </dl><h5 id=parsing-main-inhead><span class=secno>12.2.5.7 </span>The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h5>
+  </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>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inhead title="insertion
-  mode: in head">in head</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</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 that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
@@ -81418,10 +81449,9 @@
 
    </dd>
 
-  </dl><h5 id=parsing-main-inheadnoscript><span class=secno>12.2.5.8 </span>The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h5>
+  </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>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inheadnoscript title="insertion
-  mode: in head noscript">in head noscript</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inheadnoscript title="insertion mode: in head noscript">in head noscript</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A DOCTYPE token</dt>
    <dd>
@@ -81479,10 +81509,9 @@
 
    </dd>
 
-  </dl><h5 id=the-after-head-insertion-mode><span class=secno>12.2.5.9 </span>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h5>
+  </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>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#the-after-head-insertion-mode title="insertion
-  mode: after head">after head</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</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 that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
@@ -81570,10 +81599,9 @@
     token.</p>
    </dd>
 
-  </dl><h5 id=parsing-main-inbody><span class=secno>12.2.5.10 </span>The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h5>
+  </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>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inbody title="insertion
-  mode: in body">in body</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</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 that is U+0000 NULL</dt>
    <dd>
@@ -82736,11 +82764,6 @@
     elements</a> and <a href=#acknowledge-self-closing-flag title="acknowledge self-closing
     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
 
-    <p>Otherwise, if the <a href=#insertion-mode>insertion mode</a> is not already
-    "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign
-    content</a>", switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign
-    content</a>".</p>
-
    </dd>
 
    <dt>A start tag whose tag name is "svg"</dt>
@@ -82770,11 +82793,6 @@
     elements</a> and <a href=#acknowledge-self-closing-flag title="acknowledge self-closing
     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
 
-    <p>Otherwise, if the <a href=#insertion-mode>insertion mode</a> is not already
-    "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign
-    content</a>", switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign
-    content</a>".</p>
-
    </dd>
 
    <dt>A start <!--or end--> tag whose tag name is one of: "caption",
@@ -82843,10 +82861,9 @@
 
     </ol></dd>
 
-  </dl><h5 id=parsing-main-incdata><span class=secno>12.2.5.11 </span>The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h5>
+  </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>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-incdata title="insertion
-  mode: text">text</a>", tokens must be handled as follows:</p>
+  <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>
    <dd>
@@ -82996,10 +83013,9 @@
 
    </dd>
 
-  </dl><h5 id=parsing-main-intable><span class=secno>12.2.5.12 </span>The "<dfn title="insertion mode: in table">in table</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-intable><span class=secno>12.2.5.4.9 </span>The "<dfn title="insertion mode: in table">in table</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intable title="insertion
-  mode: in table">in table</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intable title="insertion mode: in table">in table</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>
    <dd>
@@ -83200,11 +83216,9 @@
 
 
 
-  <h5 id=parsing-main-intabletext><span class=secno>12.2.5.13 </span>The "<dfn title="insertion mode: in table text">in table text</dfn>" insertion mode</h5>
+  <h6 id=parsing-main-intabletext><span class=secno>12.2.5.4.10 </span>The "<dfn title="insertion mode: in table text">in table text</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intabletext title="insertion
-  mode: in table text">in table text</a>", tokens must be handled
-  as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intabletext title="insertion mode: in table text">in table 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 that is U+0000 NULL</dt>
    <dd>
@@ -83243,10 +83257,9 @@
 
    </dd>
 
-  </dl><h5 id=parsing-main-incaption><span class=secno>12.2.5.14 </span>The "<dfn title="insertion mode: in caption">in caption</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-incaption><span class=secno>12.2.5.4.11 </span>The "<dfn title="insertion mode: in caption">in caption</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-incaption title="insertion
-  mode: in caption">in caption</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-incaption title="insertion mode: in caption">in caption</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>An end tag whose tag name is "caption"</dt>
    <dd>
@@ -83301,10 +83314,9 @@
     mode</a>.</p>
    </dd>
 
-  </dl><h5 id=parsing-main-incolgroup><span class=secno>12.2.5.15 </span>The "<dfn title="insertion mode: in column group">in column group</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-incolgroup><span class=secno>12.2.5.4.12 </span>The "<dfn title="insertion mode: in column group">in column group</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-incolgroup title="insertion
-  mode: in column group">in column group</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</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 that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
@@ -83388,10 +83400,9 @@
 
    </dd>
 
-  </dl><h5 id=parsing-main-intbody><span class=secno>12.2.5.16 </span>The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h5>
+  </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>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intbody title="insertion
-  mode: in table body">in table body</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A start tag whose tag name is "tr"</dt>
    <dd>
@@ -83477,10 +83488,9 @@
   case</a>.</p>
 
 
-  <h5 id=parsing-main-intr><span class=secno>12.2.5.17 </span>The "<dfn title="insertion mode: in row">in row</dfn>" insertion mode</h5>
+  <h6 id=parsing-main-intr><span class=secno>12.2.5.4.14 </span>The "<dfn title="insertion mode: in row">in row</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intr title="insertion
-  mode: in row">in row</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A start tag whose tag name is one of: "th", "td"</dt>
    <dd>
@@ -83568,10 +83578,9 @@
   case</a>.</p>
 
 
-  <h5 id=parsing-main-intd><span class=secno>12.2.5.18 </span>The "<dfn title="insertion mode: in cell">in cell</dfn>" insertion mode</h5>
+  <h6 id=parsing-main-intd><span class=secno>12.2.5.4.15 </span>The "<dfn title="insertion mode: in cell">in cell</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intd title="insertion
-  mode: in cell">in cell</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>An end tag whose tag name is one of: "td", "th"</dt>
    <dd>
@@ -83662,10 +83671,9 @@
   cell</a> algorithm is invoked.</p>
 
 
-  <h5 id=parsing-main-inselect><span class=secno>12.2.5.19 </span>The "<dfn title="insertion mode: in select">in select</dfn>" insertion mode</h5>
+  <h6 id=parsing-main-inselect><span class=secno>12.2.5.4.16 </span>The "<dfn title="insertion mode: in select">in select</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inselect title="insertion
-  mode: in select">in select</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inselect title="insertion mode: in select">in select</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 that is U+0000 NULL</dt>
    <dd>
@@ -83813,10 +83821,9 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
-  </dl><h5 id=parsing-main-inselectintable><span class=secno>12.2.5.20 </span>The "<dfn title="insertion mode: in select in table">in select in table</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-inselectintable><span class=secno>12.2.5.4.17 </span>The "<dfn title="insertion mode: in select in table">in select in table</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inselectintable title="insertion
-  mode: in select in table">in select in table</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in select in table</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A start tag whose tag name is one of: "caption", "table",
    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
@@ -83845,276 +83852,10 @@
     mode</a>.</p>
    </dd>
 
-  </dl><h5 id=parsing-main-inforeign><span class=secno>12.2.5.21 </span>The "<dfn title="insertion mode: in foreign content">in foreign content</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-afterbody><span class=secno>12.2.5.4.18 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inforeign title="insertion
-  mode: in foreign content">in foreign content</a>", tokens must be
-  handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterbody title="insertion mode: after body">after body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
-  <dl class=switch><dt>Any token, if the <a href=#current-node>current node</a> is an element in the <a href=#html-namespace-0>HTML namespace</a></dt>
-   <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <a href=#current-node>current node</a> is a <a href=#mathml-text-integration-point>MathML text integration point</a></dt>
-   <dt>A start tag whose tag name is "svg", if the <a href=#current-node>current node</a> is an <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a></dt>
-   <dt>A start tag, if the <a href=#current-node>current node</a> is an <a href=#html-integration-point>HTML integration point</a></dt>
-   <dt>A character token, if the <a href=#current-node>current node</a> is an <a href=#html-integration-point>HTML integration point</a></dt>
-   <dt>An end-of-file token</dt>
-   <dd>
-
-    <ol><li><p>Process the token <a href=#using-the-rules-for>using the rules for</a> the
-     "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>"
-     <a href=#insertion-mode>insertion mode</a>, except that if those rules say to
-     reprocess the token, these steps must be finished first (i.e. the
-     insertion mode is reset by the following step before the token is
-     reprocessed).</li>
-
-     <li><p>If, after doing so, the <a href=#insertion-mode>insertion mode</a> is
-     still "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in
-     foreign content</a>", <a href=#reset-the-insertion-mode-appropriately>reset the insertion mode
-     appropriately</a>.</li>
-
-    </ol></dd>
-
-   <dt>A character token that is U+0000 NULL</dt>
-   <dd>
-
-    <p><a href=#parse-error>Parse error</a>. <a href=#insert-a-character title="insert a
-    character">Insert a U+FFFD REPLACEMENT CHARACTER character</a>
-    into the <a href=#current-node>current node</a>.</p>
-
-   </dd>
-
-   <dt>A character token that is one of U+0009 CHARACTER TABULATION,
-   U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE
-   RETURN (CR), or U+0020 SPACE</dt>
-   <dd>
-
-    <p><a href=#insert-a-character title="insert a character">Insert the token's
-    character</a> into the <a href=#current-node>current node</a>.</p>
-
-   </dd>
-
-   <dt>Any other character token</dt>
-   <dd>
-
-    <p><a href=#insert-a-character title="insert a character">Insert the token's
-    character</a> into the <a href=#current-node>current node</a>.</p>
-
-    <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
-
-   </dd>
-
-   <dt>A comment token</dt>
-   <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
-   </dd>
-
-   <dt>A DOCTYPE token</dt>
-   <dd>
-    <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
-   </dd>
-
-   <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
-   "blockquote", "body"<!--by inspection-->, "br", "center", "code",
-   "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
-   uniformly throughout the parser -->, "em", "embed", "h1", "h2",
-   "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
-   completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
-   "li", "listing"<!-- so that pre and listing can be handled
-   uniformly throughout the parser -->, "menu", "meta", "nobr",
-   "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
-   the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
-   "span", "strong", "strike"<!-- so that s and strike can be handled
-   uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
-   "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
-   list was determined empirically by studying over 6,000,000,000
-   pages that were specifically not XML pages -->
-   <dt>A start tag whose tag name is "font", if the token has any
-   attributes named "color", "face", or "size"</dt> <!-- the
-   attributes here are required so that SVG <font> will go through as
-   SVG but legacy <font>s won't -->
-
-   <dd>
-
-    <p><a href=#parse-error>Parse error</a>.</p>
-
-    <p>Pop an element from the <a href=#stack-of-open-elements>stack of open elements</a>,
-    and then keep popping more elements from the <a href=#stack-of-open-elements>stack of open
-    elements</a> until the <a href=#current-node>current node</a> is a
-    <a href=#mathml-text-integration-point>MathML text integration point</a>, an <a href=#html-integration-point>HTML
-    integration point</a>, or an element in the <a href=#html-namespace-0>HTML
-    namespace</a>.</p>
-
-    <p>Then, <a href=#reset-the-insertion-mode-appropriately>reset the insertion mode appropriately</a> and
-    reprocess the token.</p>
-
-   </dd>
-
-   <dt>Any other start tag</dt>
-   <dd>
-
-    <p>If the <a href=#current-node>current node</a> is an element in the
-    <a href=#mathml-namespace>MathML namespace</a>, <a href=#adjust-mathml-attributes>adjust MathML
-    attributes</a> for the token. (This fixes the case of MathML
-    attributes that are not all lowercase.)</p>
-
-    <p>If the <a href=#current-node>current node</a> is an element in the <a href=#svg-namespace>SVG
-    namespace</a>, and the token's tag name is one of the ones in
-    the first column of the following table, change the tag name to
-    the name given in the corresponding cell in the second
-    column. (This fixes the case of SVG elements that are not all
-    lowercase.)</p>
-
-    <table><thead><tr><th> Tag name <th> Element name
-     <tbody><tr><td> <code title="">altglyph</code> <td> <code title="">altGlyph</code>
-      <tr><td> <code title="">altglyphdef</code> <td> <code title="">altGlyphDef</code>
-      <tr><td> <code title="">altglyphitem</code> <td> <code title="">altGlyphItem</code>
-      <tr><td> <code title="">animatecolor</code> <td> <code title="">animateColor</code>
-      <tr><td> <code title="">animatemotion</code> <td> <code title="">animateMotion</code>
-      <tr><td> <code title="">animatetransform</code> <td> <code title="">animateTransform</code>
-      <tr><td> <code title="">clippath</code> <td> <code title="">clipPath</code>
-      <tr><td> <code title="">feblend</code> <td> <code title="">feBlend</code>
-      <tr><td> <code title="">fecolormatrix</code> <td> <code title="">feColorMatrix</code>
-      <tr><td> <code title="">fecomponenttransfer</code> <td> <code title="">feComponentTransfer</code>
-      <tr><td> <code title="">fecomposite</code> <td> <code title="">feComposite</code>
-      <tr><td> <code title="">feconvolvematrix</code> <td> <code title="">feConvolveMatrix</code>
-      <tr><td> <code title="">fediffuselighting</code> <td> <code title="">feDiffuseLighting</code>
-      <tr><td> <code title="">fedisplacementmap</code> <td> <code title="">feDisplacementMap</code>
-      <tr><td> <code title="">fedistantlight</code> <td> <code title="">feDistantLight</code>
-      <tr><td> <code title="">feflood</code> <td> <code title="">feFlood</code>
-      <tr><td> <code title="">fefunca</code> <td> <code title="">feFuncA</code>
-      <tr><td> <code title="">fefuncb</code> <td> <code title="">feFuncB</code>
-      <tr><td> <code title="">fefuncg</code> <td> <code title="">feFuncG</code>
-      <tr><td> <code title="">fefuncr</code> <td> <code title="">feFuncR</code>
-      <tr><td> <code title="">fegaussianblur</code> <td> <code title="">feGaussianBlur</code>
-      <tr><td> <code title="">feimage</code> <td> <code title="">feImage</code>
-      <tr><td> <code title="">femerge</code> <td> <code title="">feMerge</code>
-      <tr><td> <code title="">femergenode</code> <td> <code title="">feMergeNode</code>
-      <tr><td> <code title="">femorphology</code> <td> <code title="">feMorphology</code>
-      <tr><td> <code title="">feoffset</code> <td> <code title="">feOffset</code>
-      <tr><td> <code title="">fepointlight</code> <td> <code title="">fePointLight</code>
-      <tr><td> <code title="">fespecularlighting</code> <td> <code title="">feSpecularLighting</code>
-      <tr><td> <code title="">fespotlight</code> <td> <code title="">feSpotLight</code>
-      <tr><td> <code title="">fetile</code> <td> <code title="">feTile</code>
-      <tr><td> <code title="">feturbulence</code> <td> <code title="">feTurbulence</code>
-      <tr><td> <code title="">foreignobject</code> <td> <code title="">foreignObject</code>
-      <tr><td> <code title="">glyphref</code> <td> <code title="">glyphRef</code>
-      <tr><td> <code title="">lineargradient</code> <td> <code title="">linearGradient</code>
-      <tr><td> <code title="">radialgradient</code> <td> <code title="">radialGradient</code>
-      <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
-      <tr><td> <code title="">textpath</code> <td> <code title="">textPath</code>
-    </table><p>If the <a href=#current-node>current node</a> is an element in the <a href=#svg-namespace>SVG
-    namespace</a>, <a href=#adjust-svg-attributes>adjust SVG attributes</a> for the
-    token. (This fixes the case of SVG attributes that are not all
-    lowercase.)</p>
-
-    <p><a href=#adjust-foreign-attributes>Adjust foreign attributes</a> for the token. (This
-    fixes the use of namespaced attributes, in particular XLink in
-    SVG.)</p>
-
-    <p><a href=#insert-a-foreign-element>Insert a foreign element</a> for the token, in the
-    same namespace as the <a href=#current-node>current node</a>.</p>
-
-    <p>If the token has its <i>self-closing flag</i> set, pop the
-    <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
-    elements</a> and <a href=#acknowledge-self-closing-flag title="acknowledge self-closing
-    flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
-
-   </dd>
-
-   <dt id=scriptForeignEndTag>An end tag whose tag name is "script", if the <a href=#current-node>current node</a> is a <code title="">script</code> element in the <a href=#svg-namespace>SVG namespace</a></dt>
-   <dd>
-
-    <p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
-    elements</a>.</p>
-
-    <p>Let the <var title="">old insertion point</var> have the
-    same value as the current <a href=#insertion-point>insertion point</a>. Let
-    the <a href=#insertion-point>insertion point</a> be just before the <a href=#next-input-character>next
-    input character</a>.</p>
-
-    <p>Increment the parser's <a href=#script-nesting-level>script nesting level</a> by
-    one. Set the <a href=#parser-pause-flag>parser pause flag</a> to true.</p>
-
-    <p><a href=http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing>Process
-    the <code title="">script</code> element</a> according to the SVG
-    rules, if the user agent supports SVG. <a href=#refsSVG>[SVG]</a></p>
-
-    <p class=note>Even if this causes <a href=#dom-document-write title=dom-document-write>new characters to be inserted into the
-    tokenizer</a>, the parser will not be executed reentrantly,
-    since the <a href=#parser-pause-flag>parser pause flag</a> is true.</p>
-
-    <p>Decrement the parser's <a href=#script-nesting-level>script nesting level</a> by
-    one. If the parser's <a href=#script-nesting-level>script nesting level</a> is zero,
-    then set the <a href=#parser-pause-flag>parser pause flag</a> to false.</p>
-
-    <p>Let the <a href=#insertion-point>insertion point</a> have the value of the <var title="">old insertion point</var>. (In other words, restore the
-    <a href=#insertion-point>insertion point</a> to its previous value. This value
-    might be the "undefined" value.)</p>
-
-   </dd>
-
-   <dt>Any other end tag</dt>
-
-   <dd>
-
-    <p>Run these steps:</p>
-
-    <ol><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>If <var title="">node</var> is not an element with the
-     same tag name as the token, then this is a <a href=#parse-error>parse
-     error</a>.</li>
-
-     <li><p><i>Loop</i>: If <var title="">node</var>'s tag name,
-     <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>, is the same as as the
-     tag name of the token, pop elements from the <a href=#stack-of-open-elements>stack of open
-     elements</a> until <var title="">node</var> has been popped
-     from the stack, and then jump to the last step of this list of
-     steps.</li>
-
-     <li><p>Set <var title="">node</var> to the previous entry in the
-     <a href=#stack-of-open-elements>stack of open elements</a>.</li>
-
-     <li><p>If <var title="">node</var> is not an element in the
-     <a href=#html-namespace-0>HTML namespace</a>, return to the step labeled
-     <i>loop</i>.</li>
-
-     <li><p>Otherwise, process the token <a href=#using-the-rules-for>using the rules
-     for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in
-     body</a>" <a href=#insertion-mode>insertion mode</a>, except that if those
-     rules say to reprocess the token, these steps must be finished
-     first (i.e. the insertion mode is reset by the following step
-     before the token is reprocessed).</li>
-
-     <li><p>If the <a href=#insertion-mode>insertion mode</a> is still "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign
-     content</a>", <a href=#reset-the-insertion-mode-appropriately>reset the insertion mode
-     appropriately</a>.</li>
-
-    </ol></dd>
-
-  </dl><p>The <a href=#current-node>current node</a> is a <dfn id=mathml-text-integration-point>MathML text
-  integration point</dfn> if it is one of the following elements:</p>
-
-  <ul class=brief><li>An <code title="">mi</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
-   <li>An <code title="">mo</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
-   <li>An <code title="">mn</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
-   <li>An <code title="">ms</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
-   <li>An <code title="">mtext</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
-  </ul><p>The <a href=#current-node>current node</a> is an <dfn id=html-integration-point>HTML
-  integration point</dfn> if it is one of the following elements:</p>
-
-  <ul class=brief><li>An <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> whose start tag token had an attribute with the name "encoding" whose value was an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">text/html</code>"</li>
-   <li>An <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> whose start tag token had an attribute with the name "encoding" whose value was an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">application/xhtml+xml</code>"</li>
-   <li>A <code title="">foreignObject</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
-   <li>A <code title="">desc</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
-   <li>A <code title="">title</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
-  </ul><h5 id=parsing-main-afterbody><span class=secno>12.2.5.22 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h5>
-
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-afterbody title="insertion
-  mode: after body">after body</a>", tokens must be handled as follows:</p>
-
   <dl class=switch><dt>A character token that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
@@ -84168,10 +83909,9 @@
 
    </dd>
 
-  </dl><h5 id=parsing-main-inframeset><span class=secno>12.2.5.23 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-inframeset><span class=secno>12.2.5.4.19 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inframeset title="insertion
-  mode: in frameset">in frameset</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inframeset title="insertion mode: in frameset">in frameset</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 that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
@@ -84261,10 +84001,9 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
-  </dl><h5 id=parsing-main-afterframeset><span class=secno>12.2.5.24 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-afterframeset><span class=secno>12.2.5.4.20 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-afterframeset title="insertion
-  mode: after frameset">after frameset</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterframeset title="insertion mode: after frameset">after frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
   <dl class=switch><dt>A character token that is one of U+0009 CHARACTER
@@ -84315,10 +84054,9 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
-  </dl><h5 id=the-after-after-body-insertion-mode><span class=secno>12.2.5.25 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h5>
+  </dl><h6 id=the-after-after-body-insertion-mode><span class=secno>12.2.5.4.21 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#the-after-after-body-insertion-mode title="insertion
-  mode: after after body">after after body</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#the-after-after-body-insertion-mode title="insertion mode: after after body">after after body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A comment token</dt>
    <dd>
@@ -84349,10 +84087,9 @@
     reprocess the token.</p>
    </dd>
 
-  </dl><h5 id=the-after-after-frameset-insertion-mode><span class=secno>12.2.5.26 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h5>
+  </dl><h6 id=the-after-after-frameset-insertion-mode><span class=secno>12.2.5.4.22 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#the-after-after-frameset-insertion-mode title="insertion
-  mode: after after frameset">after after frameset</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#the-after-after-frameset-insertion-mode title="insertion mode: after after frameset">after after frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A comment token</dt>
    <dd>
@@ -84387,6 +84124,223 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
+  </dl><h5 id=parsing-main-inforeign><span class=secno>12.2.5.5 </span>The rules for parsing tokens <dfn title="insertion mode: in foreign content">in foreign content</dfn></h5>
+
+  <p>When the user agent is to apply the rules for parsing tokens in foreign content, the user agent must handle the token as follows:</p>
+
+  <dl class=switch><dt>A character token that is U+0000 NULL</dt>
+   <dd>
+
+    <p><a href=#parse-error>Parse error</a>. <a href=#insert-a-character title="insert a
+    character">Insert a U+FFFD REPLACEMENT CHARACTER character</a>
+    into the <a href=#current-node>current node</a>.</p>
+
+   </dd>
+
+   <dt>A character token that is one of U+0009 CHARACTER TABULATION,
+   U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE
+   RETURN (CR), or U+0020 SPACE</dt>
+   <dd>
+
+    <p><a href=#insert-a-character title="insert a character">Insert the token's
+    character</a> into the <a href=#current-node>current node</a>.</p>
+
+   </dd>
+
+   <dt>Any other character token</dt>
+   <dd>
+
+    <p><a href=#insert-a-character title="insert a character">Insert the token's
+    character</a> into the <a href=#current-node>current node</a>.</p>
+
+    <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
+
+   </dd>
+
+   <dt>A comment token</dt>
+   <dd>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
+    node</a> with the <code title="">data</code> attribute set to
+    the data given in the comment token.</p>
+   </dd>
+
+   <dt>A DOCTYPE token</dt>
+   <dd>
+    <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
+   </dd>
+
+   <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
+   "blockquote", "body"<!--by inspection-->, "br", "center", "code",
+   "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
+   uniformly throughout the parser -->, "em", "embed", "h1", "h2",
+   "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
+   completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
+   "li", "listing"<!-- so that pre and listing can be handled
+   uniformly throughout the parser -->, "menu", "meta", "nobr",
+   "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
+   the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
+   "span", "strong", "strike"<!-- so that s and strike can be handled
+   uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
+   "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
+   list was determined empirically by studying over 6,000,000,000
+   pages that were specifically not XML pages -->
+   <dt>A start tag whose tag name is "font", if the token has any
+   attributes named "color", "face", or "size"</dt> <!-- the
+   attributes here are required so that SVG <font> will go through as
+   SVG but legacy <font>s won't -->
+
+   <dd>
+
+    <p><a href=#parse-error>Parse error</a>.</p>
+
+    <p>Pop an element from the <a href=#stack-of-open-elements>stack of open elements</a>,
+    and then keep popping more elements from the <a href=#stack-of-open-elements>stack of open
+    elements</a> until the <a href=#current-node>current node</a> is a
+    <a href=#mathml-text-integration-point>MathML text integration point</a>, an <a href=#html-integration-point>HTML
+    integration point</a>, or an element in the <a href=#html-namespace-0>HTML
+    namespace</a>.</p>
+
+    <p>Then, reprocess the token.</p>
+
+   </dd>
+
+   <dt>Any other start tag</dt>
+   <dd>
+
+    <p>If the <a href=#current-node>current node</a> is an element in the
+    <a href=#mathml-namespace>MathML namespace</a>, <a href=#adjust-mathml-attributes>adjust MathML
+    attributes</a> for the token. (This fixes the case of MathML
+    attributes that are not all lowercase.)</p>
+
+    <p>If the <a href=#current-node>current node</a> is an element in the <a href=#svg-namespace>SVG
+    namespace</a>, and the token's tag name is one of the ones in
+    the first column of the following table, change the tag name to
+    the name given in the corresponding cell in the second
+    column. (This fixes the case of SVG elements that are not all
+    lowercase.)</p>
+
+    <table><thead><tr><th> Tag name <th> Element name
+     <tbody><tr><td> <code title="">altglyph</code> <td> <code title="">altGlyph</code>
+      <tr><td> <code title="">altglyphdef</code> <td> <code title="">altGlyphDef</code>
+      <tr><td> <code title="">altglyphitem</code> <td> <code title="">altGlyphItem</code>
+      <tr><td> <code title="">animatecolor</code> <td> <code title="">animateColor</code>
+      <tr><td> <code title="">animatemotion</code> <td> <code title="">animateMotion</code>
+      <tr><td> <code title="">animatetransform</code> <td> <code title="">animateTransform</code>
+      <tr><td> <code title="">clippath</code> <td> <code title="">clipPath</code>
+      <tr><td> <code title="">feblend</code> <td> <code title="">feBlend</code>
+      <tr><td> <code title="">fecolormatrix</code> <td> <code title="">feColorMatrix</code>
+      <tr><td> <code title="">fecomponenttransfer</code> <td> <code title="">feComponentTransfer</code>
+      <tr><td> <code title="">fecomposite</code> <td> <code title="">feComposite</code>
+      <tr><td> <code title="">feconvolvematrix</code> <td> <code title="">feConvolveMatrix</code>
+      <tr><td> <code title="">fediffuselighting</code> <td> <code title="">feDiffuseLighting</code>
+      <tr><td> <code title="">fedisplacementmap</code> <td> <code title="">feDisplacementMap</code>
+      <tr><td> <code title="">fedistantlight</code> <td> <code title="">feDistantLight</code>
+      <tr><td> <code title="">feflood</code> <td> <code title="">feFlood</code>
+      <tr><td> <code title="">fefunca</code> <td> <code title="">feFuncA</code>
+      <tr><td> <code title="">fefuncb</code> <td> <code title="">feFuncB</code>
+      <tr><td> <code title="">fefuncg</code> <td> <code title="">feFuncG</code>
+      <tr><td> <code title="">fefuncr</code> <td> <code title="">feFuncR</code>
+      <tr><td> <code title="">fegaussianblur</code> <td> <code title="">feGaussianBlur</code>
+      <tr><td> <code title="">feimage</code> <td> <code title="">feImage</code>
+      <tr><td> <code title="">femerge</code> <td> <code title="">feMerge</code>
+      <tr><td> <code title="">femergenode</code> <td> <code title="">feMergeNode</code>
+      <tr><td> <code title="">femorphology</code> <td> <code title="">feMorphology</code>
+      <tr><td> <code title="">feoffset</code> <td> <code title="">feOffset</code>
+      <tr><td> <code title="">fepointlight</code> <td> <code title="">fePointLight</code>
+      <tr><td> <code title="">fespecularlighting</code> <td> <code title="">feSpecularLighting</code>
+      <tr><td> <code title="">fespotlight</code> <td> <code title="">feSpotLight</code>
+      <tr><td> <code title="">fetile</code> <td> <code title="">feTile</code>
+      <tr><td> <code title="">feturbulence</code> <td> <code title="">feTurbulence</code>
+      <tr><td> <code title="">foreignobject</code> <td> <code title="">foreignObject</code>
+      <tr><td> <code title="">glyphref</code> <td> <code title="">glyphRef</code>
+      <tr><td> <code title="">lineargradient</code> <td> <code title="">linearGradient</code>
+      <tr><td> <code title="">radialgradient</code> <td> <code title="">radialGradient</code>
+      <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
+      <tr><td> <code title="">textpath</code> <td> <code title="">textPath</code>
+    </table><p>If the <a href=#current-node>current node</a> is an element in the <a href=#svg-namespace>SVG
+    namespace</a>, <a href=#adjust-svg-attributes>adjust SVG attributes</a> for the
+    token. (This fixes the case of SVG attributes that are not all
+    lowercase.)</p>
+
+    <p><a href=#adjust-foreign-attributes>Adjust foreign attributes</a> for the token. (This
+    fixes the use of namespaced attributes, in particular XLink in
+    SVG.)</p>
+
+    <p><a href=#insert-a-foreign-element>Insert a foreign element</a> for the token, in the
+    same namespace as the <a href=#current-node>current node</a>.</p>
+
+    <p>If the token has its <i>self-closing flag</i> set, pop the
+    <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
+    elements</a> and <a href=#acknowledge-self-closing-flag title="acknowledge self-closing
+    flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
+
+   </dd>
+
+   <dt id=scriptForeignEndTag>An end tag whose tag name is "script", if the <a href=#current-node>current node</a> is a <code title="">script</code> element in the <a href=#svg-namespace>SVG namespace</a></dt>
+   <dd>
+
+    <p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
+
+    <p>Let the <var title="">old insertion point</var> have the
+    same value as the current <a href=#insertion-point>insertion point</a>. Let
+    the <a href=#insertion-point>insertion point</a> be just before the <a href=#next-input-character>next
+    input character</a>.</p>
+
+    <p>Increment the parser's <a href=#script-nesting-level>script nesting level</a> by
+    one. Set the <a href=#parser-pause-flag>parser pause flag</a> to true.</p>
+
+    <p><a href=http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing>Process
+    the <code title="">script</code> element</a> according to the SVG
+    rules, if the user agent supports SVG. <a href=#refsSVG>[SVG]</a></p>
+
+    <p class=note>Even if this causes <a href=#dom-document-write title=dom-document-write>new characters to be inserted into the
+    tokenizer</a>, the parser will not be executed reentrantly,
+    since the <a href=#parser-pause-flag>parser pause flag</a> is true.</p>
+
+    <p>Decrement the parser's <a href=#script-nesting-level>script nesting level</a> by
+    one. If the parser's <a href=#script-nesting-level>script nesting level</a> is zero,
+    then set the <a href=#parser-pause-flag>parser pause flag</a> to false.</p>
+
+    <p>Let the <a href=#insertion-point>insertion point</a> have the value of the <var title="">old insertion point</var>. (In other words, restore the
+    <a href=#insertion-point>insertion point</a> to its previous value. This value
+    might be the "undefined" value.)</p>
+
+   </dd>
+
+   <dt>Any other end tag</dt>
+
+   <dd>
+
+    <p>Run these steps:</p>
+
+    <ol><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>If <var title="">node</var> is not an element with the
+     same tag name as the token, then this is a <a href=#parse-error>parse
+     error</a>.</li>
+
+     <li><p><i>Loop</i>: If <var title="">node</var>'s tag name,
+     <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>, is the same as as the
+     tag name of the token, pop elements from the <a href=#stack-of-open-elements>stack of open
+     elements</a> until <var title="">node</var> has been popped
+     from the stack, and then jump to the last step of this list of
+     steps.</li>
+
+     <li><p>Set <var title="">node</var> to the previous entry in the
+     <a href=#stack-of-open-elements>stack of open elements</a>.</li>
+
+     <li><p>If <var title="">node</var> is not an element in the
+     <a href=#html-namespace-0>HTML namespace</a>, return to the step labeled
+     <i>loop</i>.</li>
+
+     <li><p>Otherwise, process the token according to the rules given
+     in the section corresponding to the current <a href=#insertion-mode>insertion
+     mode</a> in HTML content.</li>
+
+    </ol></dd>
+
   </dl></div>
 
 

Modified: index
===================================================================
--- index	2011-02-27 00:03:26 UTC (rev 5919)
+++ index	2011-02-28 23:56:22 UTC (rev 5920)
@@ -243,7 +243,7 @@
 
   <header class=head id=head><p><a class=logo href=http://www.whatwg.org/ rel=home><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 27 February 2011</h2>
+    <h2 class="no-num no-toc">Living Standard — Last Updated 28 February 2011</h2>
    </hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
    <p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
    <!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
@@ -1148,29 +1148,31 @@
        <li><a href=#creating-and-inserting-elements><span class=secno>10.2.5.1 </span>Creating and inserting elements</a></li>
        <li><a href=#closing-elements-that-have-implied-end-tags><span class=secno>10.2.5.2 </span>Closing elements that have implied end tags</a></li>
        <li><a href=#foster-parenting><span class=secno>10.2.5.3 </span>Foster parenting</a></li>
-       <li><a href=#the-initial-insertion-mode><span class=secno>10.2.5.4 </span>The "initial" insertion mode</a></li>
-       <li><a href=#the-before-html-insertion-mode><span class=secno>10.2.5.5 </span>The "before html" insertion mode</a></li>
-       <li><a href=#the-before-head-insertion-mode><span class=secno>10.2.5.6 </span>The "before head" insertion mode</a></li>
-       <li><a href=#parsing-main-inhead><span class=secno>10.2.5.7 </span>The "in head" insertion mode</a></li>
-       <li><a href=#parsing-main-inheadnoscript><span class=secno>10.2.5.8 </span>The "in head noscript" insertion mode</a></li>
-       <li><a href=#the-after-head-insertion-mode><span class=secno>10.2.5.9 </span>The "after head" insertion mode</a></li>
-       <li><a href=#parsing-main-inbody><span class=secno>10.2.5.10 </span>The "in body" insertion mode</a></li>
-       <li><a href=#parsing-main-incdata><span class=secno>10.2.5.11 </span>The "text" insertion mode</a></li>
-       <li><a href=#parsing-main-intable><span class=secno>10.2.5.12 </span>The "in table" insertion mode</a></li>
-       <li><a href=#parsing-main-intabletext><span class=secno>10.2.5.13 </span>The "in table text" insertion mode</a></li>
-       <li><a href=#parsing-main-incaption><span class=secno>10.2.5.14 </span>The "in caption" insertion mode</a></li>
-       <li><a href=#parsing-main-incolgroup><span class=secno>10.2.5.15 </span>The "in column group" insertion mode</a></li>
-       <li><a href=#parsing-main-intbody><span class=secno>10.2.5.16 </span>The "in table body" insertion mode</a></li>
-       <li><a href=#parsing-main-intr><span class=secno>10.2.5.17 </span>The "in row" insertion mode</a></li>
-       <li><a href=#parsing-main-intd><span class=secno>10.2.5.18 </span>The "in cell" insertion mode</a></li>
-       <li><a href=#parsing-main-inselect><span class=secno>10.2.5.19 </span>The "in select" insertion mode</a></li>
-       <li><a href=#parsing-main-inselectintable><span class=secno>10.2.5.20 </span>The "in select in table" insertion mode</a></li>
-       <li><a href=#parsing-main-inforeign><span class=secno>10.2.5.21 </span>The "in foreign content" insertion mode</a></li>
-       <li><a href=#parsing-main-afterbody><span class=secno>10.2.5.22 </span>The "after body" insertion mode</a></li>
-       <li><a href=#parsing-main-inframeset><span class=secno>10.2.5.23 </span>The "in frameset" insertion mode</a></li>
-       <li><a href=#parsing-main-afterframeset><span class=secno>10.2.5.24 </span>The "after frameset" insertion mode</a></li>
-       <li><a href=#the-after-after-body-insertion-mode><span class=secno>10.2.5.25 </span>The "after after body" insertion mode</a></li>
-       <li><a href=#the-after-after-frameset-insertion-mode><span class=secno>10.2.5.26 </span>The "after after frameset" insertion mode</a></ol></li>
+       <li><a href=#parsing-main-inhtml><span class=secno>10.2.5.4 </span>The rules for parsing tokens in HTML content</a>
+        <ol>
+         <li><a href=#the-initial-insertion-mode><span class=secno>10.2.5.4.1 </span>The "initial" insertion mode</a></li>
+         <li><a href=#the-before-html-insertion-mode><span class=secno>10.2.5.4.2 </span>The "before html" insertion mode</a></li>
+         <li><a href=#the-before-head-insertion-mode><span class=secno>10.2.5.4.3 </span>The "before head" insertion mode</a></li>
+         <li><a href=#parsing-main-inhead><span class=secno>10.2.5.4.4 </span>The "in head" insertion mode</a></li>
+         <li><a href=#parsing-main-inheadnoscript><span class=secno>10.2.5.4.5 </span>The "in head noscript" insertion mode</a></li>
+         <li><a href=#the-after-head-insertion-mode><span class=secno>10.2.5.4.6 </span>The "after head" insertion mode</a></li>
+         <li><a href=#parsing-main-inbody><span class=secno>10.2.5.4.7 </span>The "in body" insertion mode</a></li>
+         <li><a href=#parsing-main-incdata><span class=secno>10.2.5.4.8 </span>The "text" insertion mode</a></li>
+         <li><a href=#parsing-main-intable><span class=secno>10.2.5.4.9 </span>The "in table" insertion mode</a></li>
+         <li><a href=#parsing-main-intabletext><span class=secno>10.2.5.4.10 </span>The "in table text" insertion mode</a></li>
+         <li><a href=#parsing-main-incaption><span class=secno>10.2.5.4.11 </span>The "in caption" insertion mode</a></li>
+         <li><a href=#parsing-main-incolgroup><span class=secno>10.2.5.4.12 </span>The "in column group" insertion mode</a></li>
+         <li><a href=#parsing-main-intbody><span class=secno>10.2.5.4.13 </span>The "in table body" insertion mode</a></li>
+         <li><a href=#parsing-main-intr><span class=secno>10.2.5.4.14 </span>The "in row" insertion mode</a></li>
+         <li><a href=#parsing-main-intd><span class=secno>10.2.5.4.15 </span>The "in cell" insertion mode</a></li>
+         <li><a href=#parsing-main-inselect><span class=secno>10.2.5.4.16 </span>The "in select" insertion mode</a></li>
+         <li><a href=#parsing-main-inselectintable><span class=secno>10.2.5.4.17 </span>The "in select in table" insertion mode</a></li>
+         <li><a href=#parsing-main-afterbody><span class=secno>10.2.5.4.18 </span>The "after body" insertion mode</a></li>
+         <li><a href=#parsing-main-inframeset><span class=secno>10.2.5.4.19 </span>The "in frameset" insertion mode</a></li>
+         <li><a href=#parsing-main-afterframeset><span class=secno>10.2.5.4.20 </span>The "after frameset" insertion mode</a></li>
+         <li><a href=#the-after-after-body-insertion-mode><span class=secno>10.2.5.4.21 </span>The "after after body" insertion mode</a></li>
+         <li><a href=#the-after-after-frameset-insertion-mode><span class=secno>10.2.5.4.22 </span>The "after after frameset" insertion mode</a></ol></li>
+       <li><a href=#parsing-main-inforeign><span class=secno>10.2.5.5 </span>The rules for parsing tokens in foreign content</a></ol></li>
      <li><a href=#the-end><span class=secno>10.2.6 </span>The end</a></li>
      <li><a href=#coercing-an-html-dom-into-an-infoset><span class=secno>10.2.7 </span>Coercing an HTML DOM into an infoset</a></li>
      <li><a href=#an-introduction-to-error-handling-and-strange-cases-in-the-parser><span class=secno>10.2.8 </span>An introduction to error handling and strange cases in the parser</a>
@@ -73953,12 +73955,16 @@
   "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before html</a>",
   "<a href=#the-before-head-insertion-mode title="insertion mode: before head">before head</a>",
   "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>", "<a href=#parsing-main-inheadnoscript title="insertion mode: in head noscript">in head noscript</a>",
-  "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</a>", "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>", "<a href=#parsing-main-incdata title="insertion mode: text">text</a>",
-  "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>", "<a href=#parsing-main-intabletext title="insertion mode: in table text">in table text</a>", "<a href=#parsing-main-incaption title="insertion mode: in caption">in caption</a>", "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</a>",
-  "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>",
-  "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>", "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>", "<a href=#parsing-main-inselect title="insertion mode: in select">in select</a>", "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in select in
-  table</a>", "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in
-  foreign content</a>", "<a href=#parsing-main-afterbody title="insertion mode: after
+  "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</a>", "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>", "<a href=#parsing-main-incdata title="insertion mode: text">text</a>", "<a href=#parsing-main-intable title="insertion
+  mode: in table">in table</a>", "<a href=#parsing-main-intabletext title="insertion mode: in
+  table text">in table text</a>", "<a href=#parsing-main-incaption title="insertion mode: in
+  caption">in caption</a>", "<a href=#parsing-main-incolgroup title="insertion mode: in column
+  group">in column group</a>", "<a href=#parsing-main-intbody title="insertion mode: in
+  table body">in table body</a>", "<a href=#parsing-main-intr title="insertion mode: in
+  row">in row</a>", "<a href=#parsing-main-intd title="insertion mode: in cell">in
+  cell</a>", "<a href=#parsing-main-inselect title="insertion mode: in select">in
+  select</a>", "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in
+  select in table</a>", "<a href=#parsing-main-afterbody title="insertion mode: after
   body">after body</a>", "<a href=#parsing-main-inframeset title="insertion mode: in
   frameset">in frameset</a>", "<a href=#parsing-main-afterframeset title="insertion mode: after
   frameset">after frameset</a>", "<a href=#the-after-after-body-insertion-mode title="insertion mode:
@@ -74063,12 +74069,6 @@
    non-null when we're going through these steps, we'll need to
    uncomment out the commented-out bits -->
 
-   <li>If <var title="">node</var> is an element from the <a href=#mathml-namespace>MathML
-   namespace</a> or the <a href=#svg-namespace>SVG namespace</a>, then switch the
-   <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inforeign title="insertion mode: in
-   foreign content">in foreign content</a>" and abort these
-   steps.</li>
-
    <li>If <var title="">last</var> is true, then switch the
    <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in
    body">in body</a>" and abort these steps. (<a href=#fragment-case>fragment
@@ -75676,11 +75676,10 @@
   case-insensitive</a> match for the word "DOCTYPE", then consume
   those characters and switch to the <a href=#doctype-state>DOCTYPE state</a>.</p>
 
-  <p>Otherwise, if the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign
-  content</a>" and the <a href=#current-node>current node</a> is not an element
-  in the <a href=#html-namespace-0>HTML namespace</a> and the next seven characters are
-  an <a href=#case-sensitive>case-sensitive</a> match for the string "[CDATA[" (the
-  five uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
+  <p>Otherwise, if the <a href=#current-node>current node</a> is not an element in
+  the <a href=#html-namespace-0>HTML namespace</a> and the next seven characters are an
+  <a href=#case-sensitive>case-sensitive</a> match for the string "[CDATA[" (the five
+  uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
   character before and after), then consume those characters and
   switch to the <a href=#cdata-section-state>CDATA section state</a>.</p>
 
@@ -76582,11 +76581,44 @@
   has to render the <code><a href=#document>Document</a></code> so that it is available to
   the user, or when it has to begin accepting user input.</p>
 
-  <p>As each token is emitted from the tokenizer, the user agent must
-  process the token according to the rules given in the section
-  corresponding to the current <a href=#insertion-mode>insertion mode</a>.</p>
+  <hr><p>As each token is emitted from the tokenizer, the user agent must
+  follow the appropriate steps from the following list:</p>
 
-  <p>When the steps below require the UA to <dfn id=insert-a-character>insert a
+  <dl class=switch><dt>If there is no <a href=#current-node>current node</a></dt>
+   <dt>If the <a href=#current-node>current node</a> is an element in the <a href=#html-namespace-0>HTML namespace</a></dt>
+   <dt>If the <a href=#current-node>current node</a> is a <a href=#mathml-text-integration-point>MathML text integration point</a> and the token is a start tag whose tag name is neither "mglyph" nor "malignmark"</dt>
+   <dt>If the <a href=#current-node>current node</a> is an <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> and the token is a start tag whose tag name is "svg"</dt>
+   <dt>If the <a href=#current-node>current node</a> is an <a href=#html-integration-point>HTML integration point</a> and the token is a start tag</dt>
+   <dt>If the <a href=#current-node>current node</a> is an <a href=#html-integration-point>HTML integration point</a> and the token is a character token</dt>
+   <dt>If the token is an end-of-file token</dt>
+
+   <dd>Process the token according to the rules given in the section
+   corresponding to the current <a href=#insertion-mode>insertion mode</a> in HTML
+   content.</dd>
+
+   <dt>Otherwise</dt>
+
+   <dd>Process the token according to the rules given in the section
+   for parsing tokens <a href=#parsing-main-inforeign title="insertion mode: in foreign
+   content">in foreign content</a>.</dd>
+
+  </dl><p>The <a href=#current-node>current node</a> is a <dfn id=mathml-text-integration-point>MathML text
+  integration point</dfn> if it is one of the following elements:</p>
+
+  <ul class=brief><li>An <code title="">mi</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
+   <li>An <code title="">mo</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
+   <li>An <code title="">mn</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
+   <li>An <code title="">ms</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
+   <li>An <code title="">mtext</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
+  </ul><p>The <a href=#current-node>current node</a> is an <dfn id=html-integration-point>HTML
+  integration point</dfn> if it is one of the following elements:</p>
+
+  <ul class=brief><li>An <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> whose start tag token had an attribute with the name "encoding" whose value was an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">text/html</code>"</li>
+   <li>An <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> whose start tag token had an attribute with the name "encoding" whose value was an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">application/xhtml+xml</code>"</li>
+   <li>A <code title="">foreignObject</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
+   <li>A <code title="">desc</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
+   <li>A <code title="">title</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
+  </ul><hr><p>When the steps below require the UA to <dfn id=insert-a-character>insert a
   character</dfn> into a node, if that node has a child immediately
   before where the character is to be inserted, and that child is a
   <code><a href=#text>Text</a></code> node, then the character must be appended to that
@@ -76878,11 +76910,13 @@
 
 
 
-  <h5 id=the-initial-insertion-mode><span class=secno>10.2.5.4 </span>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h5>
+  <h5 id=parsing-main-inhtml><span class=secno>10.2.5.4 </span>The rules for parsing tokens in HTML content</h5>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#the-initial-insertion-mode title="insertion
-  mode: initial">initial</a>", tokens must be handled as follows:</p>
 
+  <h6 id=the-initial-insertion-mode><span class=secno>10.2.5.4.1 </span>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h6>
+
+  <p>When the user agent is to apply the rules for the "<a href=#the-initial-insertion-mode title="insertion mode: initial">initial</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 that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
@@ -77072,10 +77106,9 @@
 
    </dd>
 
-  </dl><h5 id=the-before-html-insertion-mode><span class=secno>10.2.5.5 </span>The "<dfn title="insertion mode: before html">before html</dfn>" insertion mode</h5>
+  </dl><h6 id=the-before-html-insertion-mode><span class=secno>10.2.5.4.2 </span>The "<dfn title="insertion mode: before html">before html</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#the-before-html-insertion-mode title="insertion
-  mode: before html">before html</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before html</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A DOCTYPE token</dt>
    <dd>
@@ -77156,10 +77189,9 @@
   as described in the next section.</p>
 
 
-  <h5 id=the-before-head-insertion-mode><span class=secno>10.2.5.6 </span>The "<dfn title="insertion mode: before head">before head</dfn>" insertion mode</h5>
+  <h6 id=the-before-head-insertion-mode><span class=secno>10.2.5.4.3 </span>The "<dfn title="insertion mode: before head">before head</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#the-before-head-insertion-mode title="insertion
-  mode: before head">before head</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#the-before-head-insertion-mode title="insertion mode: before head">before head</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 that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
@@ -77222,10 +77254,9 @@
 
    </dd>
 
-  </dl><h5 id=parsing-main-inhead><span class=secno>10.2.5.7 </span>The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-inhead><span class=secno>10.2.5.4.4 </span>The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inhead title="insertion
-  mode: in head">in head</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</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 that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
@@ -77389,10 +77420,9 @@
 
    </dd>
 
-  </dl><h5 id=parsing-main-inheadnoscript><span class=secno>10.2.5.8 </span>The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-inheadnoscript><span class=secno>10.2.5.4.5 </span>The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inheadnoscript title="insertion
-  mode: in head noscript">in head noscript</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inheadnoscript title="insertion mode: in head noscript">in head noscript</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A DOCTYPE token</dt>
    <dd>
@@ -77450,10 +77480,9 @@
 
    </dd>
 
-  </dl><h5 id=the-after-head-insertion-mode><span class=secno>10.2.5.9 </span>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h5>
+  </dl><h6 id=the-after-head-insertion-mode><span class=secno>10.2.5.4.6 </span>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#the-after-head-insertion-mode title="insertion
-  mode: after head">after head</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</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 that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
@@ -77541,10 +77570,9 @@
     token.</p>
    </dd>
 
-  </dl><h5 id=parsing-main-inbody><span class=secno>10.2.5.10 </span>The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-inbody><span class=secno>10.2.5.4.7 </span>The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inbody title="insertion
-  mode: in body">in body</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</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 that is U+0000 NULL</dt>
    <dd>
@@ -78707,11 +78735,6 @@
     elements</a> and <a href=#acknowledge-self-closing-flag title="acknowledge self-closing
     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
 
-    <p>Otherwise, if the <a href=#insertion-mode>insertion mode</a> is not already
-    "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign
-    content</a>", switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign
-    content</a>".</p>
-
    </dd>
 
    <dt>A start tag whose tag name is "svg"</dt>
@@ -78741,11 +78764,6 @@
     elements</a> and <a href=#acknowledge-self-closing-flag title="acknowledge self-closing
     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
 
-    <p>Otherwise, if the <a href=#insertion-mode>insertion mode</a> is not already
-    "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign
-    content</a>", switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign
-    content</a>".</p>
-
    </dd>
 
    <dt>A start <!--or end--> tag whose tag name is one of: "caption",
@@ -78814,10 +78832,9 @@
 
     </ol></dd>
 
-  </dl><h5 id=parsing-main-incdata><span class=secno>10.2.5.11 </span>The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-incdata><span class=secno>10.2.5.4.8 </span>The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-incdata title="insertion
-  mode: text">text</a>", tokens must be handled as follows:</p>
+  <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>
    <dd>
@@ -78967,10 +78984,9 @@
 
    </dd>
 
-  </dl><h5 id=parsing-main-intable><span class=secno>10.2.5.12 </span>The "<dfn title="insertion mode: in table">in table</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-intable><span class=secno>10.2.5.4.9 </span>The "<dfn title="insertion mode: in table">in table</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intable title="insertion
-  mode: in table">in table</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intable title="insertion mode: in table">in table</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>
    <dd>
@@ -79171,11 +79187,9 @@
 
 
 
-  <h5 id=parsing-main-intabletext><span class=secno>10.2.5.13 </span>The "<dfn title="insertion mode: in table text">in table text</dfn>" insertion mode</h5>
+  <h6 id=parsing-main-intabletext><span class=secno>10.2.5.4.10 </span>The "<dfn title="insertion mode: in table text">in table text</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intabletext title="insertion
-  mode: in table text">in table text</a>", tokens must be handled
-  as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intabletext title="insertion mode: in table text">in table 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 that is U+0000 NULL</dt>
    <dd>
@@ -79214,10 +79228,9 @@
 
    </dd>
 
-  </dl><h5 id=parsing-main-incaption><span class=secno>10.2.5.14 </span>The "<dfn title="insertion mode: in caption">in caption</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-incaption><span class=secno>10.2.5.4.11 </span>The "<dfn title="insertion mode: in caption">in caption</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-incaption title="insertion
-  mode: in caption">in caption</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-incaption title="insertion mode: in caption">in caption</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>An end tag whose tag name is "caption"</dt>
    <dd>
@@ -79272,10 +79285,9 @@
     mode</a>.</p>
    </dd>
 
-  </dl><h5 id=parsing-main-incolgroup><span class=secno>10.2.5.15 </span>The "<dfn title="insertion mode: in column group">in column group</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-incolgroup><span class=secno>10.2.5.4.12 </span>The "<dfn title="insertion mode: in column group">in column group</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-incolgroup title="insertion
-  mode: in column group">in column group</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</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 that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
@@ -79359,10 +79371,9 @@
 
    </dd>
 
-  </dl><h5 id=parsing-main-intbody><span class=secno>10.2.5.16 </span>The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-intbody><span class=secno>10.2.5.4.13 </span>The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intbody title="insertion
-  mode: in table body">in table body</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A start tag whose tag name is "tr"</dt>
    <dd>
@@ -79448,10 +79459,9 @@
   case</a>.</p>
 
 
-  <h5 id=parsing-main-intr><span class=secno>10.2.5.17 </span>The "<dfn title="insertion mode: in row">in row</dfn>" insertion mode</h5>
+  <h6 id=parsing-main-intr><span class=secno>10.2.5.4.14 </span>The "<dfn title="insertion mode: in row">in row</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intr title="insertion
-  mode: in row">in row</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A start tag whose tag name is one of: "th", "td"</dt>
    <dd>
@@ -79539,10 +79549,9 @@
   case</a>.</p>
 
 
-  <h5 id=parsing-main-intd><span class=secno>10.2.5.18 </span>The "<dfn title="insertion mode: in cell">in cell</dfn>" insertion mode</h5>
+  <h6 id=parsing-main-intd><span class=secno>10.2.5.4.15 </span>The "<dfn title="insertion mode: in cell">in cell</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-intd title="insertion
-  mode: in cell">in cell</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>An end tag whose tag name is one of: "td", "th"</dt>
    <dd>
@@ -79633,10 +79642,9 @@
   cell</a> algorithm is invoked.</p>
 
 
-  <h5 id=parsing-main-inselect><span class=secno>10.2.5.19 </span>The "<dfn title="insertion mode: in select">in select</dfn>" insertion mode</h5>
+  <h6 id=parsing-main-inselect><span class=secno>10.2.5.4.16 </span>The "<dfn title="insertion mode: in select">in select</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inselect title="insertion
-  mode: in select">in select</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inselect title="insertion mode: in select">in select</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 that is U+0000 NULL</dt>
    <dd>
@@ -79784,10 +79792,9 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
-  </dl><h5 id=parsing-main-inselectintable><span class=secno>10.2.5.20 </span>The "<dfn title="insertion mode: in select in table">in select in table</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-inselectintable><span class=secno>10.2.5.4.17 </span>The "<dfn title="insertion mode: in select in table">in select in table</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inselectintable title="insertion
-  mode: in select in table">in select in table</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in select in table</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A start tag whose tag name is one of: "caption", "table",
    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
@@ -79816,276 +79823,10 @@
     mode</a>.</p>
    </dd>
 
-  </dl><h5 id=parsing-main-inforeign><span class=secno>10.2.5.21 </span>The "<dfn title="insertion mode: in foreign content">in foreign content</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-afterbody><span class=secno>10.2.5.4.18 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inforeign title="insertion
-  mode: in foreign content">in foreign content</a>", tokens must be
-  handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterbody title="insertion mode: after body">after body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
-  <dl class=switch><dt>Any token, if the <a href=#current-node>current node</a> is an element in the <a href=#html-namespace-0>HTML namespace</a></dt>
-   <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <a href=#current-node>current node</a> is a <a href=#mathml-text-integration-point>MathML text integration point</a></dt>
-   <dt>A start tag whose tag name is "svg", if the <a href=#current-node>current node</a> is an <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a></dt>
-   <dt>A start tag, if the <a href=#current-node>current node</a> is an <a href=#html-integration-point>HTML integration point</a></dt>
-   <dt>A character token, if the <a href=#current-node>current node</a> is an <a href=#html-integration-point>HTML integration point</a></dt>
-   <dt>An end-of-file token</dt>
-   <dd>
-
-    <ol><li><p>Process the token <a href=#using-the-rules-for>using the rules for</a> the
-     "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>"
-     <a href=#insertion-mode>insertion mode</a>, except that if those rules say to
-     reprocess the token, these steps must be finished first (i.e. the
-     insertion mode is reset by the following step before the token is
-     reprocessed).</li>
-
-     <li><p>If, after doing so, the <a href=#insertion-mode>insertion mode</a> is
-     still "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in
-     foreign content</a>", <a href=#reset-the-insertion-mode-appropriately>reset the insertion mode
-     appropriately</a>.</li>
-
-    </ol></dd>
-
-   <dt>A character token that is U+0000 NULL</dt>
-   <dd>
-
-    <p><a href=#parse-error>Parse error</a>. <a href=#insert-a-character title="insert a
-    character">Insert a U+FFFD REPLACEMENT CHARACTER character</a>
-    into the <a href=#current-node>current node</a>.</p>
-
-   </dd>
-
-   <dt>A character token that is one of U+0009 CHARACTER TABULATION,
-   U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE
-   RETURN (CR), or U+0020 SPACE</dt>
-   <dd>
-
-    <p><a href=#insert-a-character title="insert a character">Insert the token's
-    character</a> into the <a href=#current-node>current node</a>.</p>
-
-   </dd>
-
-   <dt>Any other character token</dt>
-   <dd>
-
-    <p><a href=#insert-a-character title="insert a character">Insert the token's
-    character</a> into the <a href=#current-node>current node</a>.</p>
-
-    <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
-
-   </dd>
-
-   <dt>A comment token</dt>
-   <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
-   </dd>
-
-   <dt>A DOCTYPE token</dt>
-   <dd>
-    <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
-   </dd>
-
-   <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
-   "blockquote", "body"<!--by inspection-->, "br", "center", "code",
-   "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
-   uniformly throughout the parser -->, "em", "embed", "h1", "h2",
-   "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
-   completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
-   "li", "listing"<!-- so that pre and listing can be handled
-   uniformly throughout the parser -->, "menu", "meta", "nobr",
-   "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
-   the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
-   "span", "strong", "strike"<!-- so that s and strike can be handled
-   uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
-   "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
-   list was determined empirically by studying over 6,000,000,000
-   pages that were specifically not XML pages -->
-   <dt>A start tag whose tag name is "font", if the token has any
-   attributes named "color", "face", or "size"</dt> <!-- the
-   attributes here are required so that SVG <font> will go through as
-   SVG but legacy <font>s won't -->
-
-   <dd>
-
-    <p><a href=#parse-error>Parse error</a>.</p>
-
-    <p>Pop an element from the <a href=#stack-of-open-elements>stack of open elements</a>,
-    and then keep popping more elements from the <a href=#stack-of-open-elements>stack of open
-    elements</a> until the <a href=#current-node>current node</a> is a
-    <a href=#mathml-text-integration-point>MathML text integration point</a>, an <a href=#html-integration-point>HTML
-    integration point</a>, or an element in the <a href=#html-namespace-0>HTML
-    namespace</a>.</p>
-
-    <p>Then, <a href=#reset-the-insertion-mode-appropriately>reset the insertion mode appropriately</a> and
-    reprocess the token.</p>
-
-   </dd>
-
-   <dt>Any other start tag</dt>
-   <dd>
-
-    <p>If the <a href=#current-node>current node</a> is an element in the
-    <a href=#mathml-namespace>MathML namespace</a>, <a href=#adjust-mathml-attributes>adjust MathML
-    attributes</a> for the token. (This fixes the case of MathML
-    attributes that are not all lowercase.)</p>
-
-    <p>If the <a href=#current-node>current node</a> is an element in the <a href=#svg-namespace>SVG
-    namespace</a>, and the token's tag name is one of the ones in
-    the first column of the following table, change the tag name to
-    the name given in the corresponding cell in the second
-    column. (This fixes the case of SVG elements that are not all
-    lowercase.)</p>
-
-    <table><thead><tr><th> Tag name <th> Element name
-     <tbody><tr><td> <code title="">altglyph</code> <td> <code title="">altGlyph</code>
-      <tr><td> <code title="">altglyphdef</code> <td> <code title="">altGlyphDef</code>
-      <tr><td> <code title="">altglyphitem</code> <td> <code title="">altGlyphItem</code>
-      <tr><td> <code title="">animatecolor</code> <td> <code title="">animateColor</code>
-      <tr><td> <code title="">animatemotion</code> <td> <code title="">animateMotion</code>
-      <tr><td> <code title="">animatetransform</code> <td> <code title="">animateTransform</code>
-      <tr><td> <code title="">clippath</code> <td> <code title="">clipPath</code>
-      <tr><td> <code title="">feblend</code> <td> <code title="">feBlend</code>
-      <tr><td> <code title="">fecolormatrix</code> <td> <code title="">feColorMatrix</code>
-      <tr><td> <code title="">fecomponenttransfer</code> <td> <code title="">feComponentTransfer</code>
-      <tr><td> <code title="">fecomposite</code> <td> <code title="">feComposite</code>
-      <tr><td> <code title="">feconvolvematrix</code> <td> <code title="">feConvolveMatrix</code>
-      <tr><td> <code title="">fediffuselighting</code> <td> <code title="">feDiffuseLighting</code>
-      <tr><td> <code title="">fedisplacementmap</code> <td> <code title="">feDisplacementMap</code>
-      <tr><td> <code title="">fedistantlight</code> <td> <code title="">feDistantLight</code>
-      <tr><td> <code title="">feflood</code> <td> <code title="">feFlood</code>
-      <tr><td> <code title="">fefunca</code> <td> <code title="">feFuncA</code>
-      <tr><td> <code title="">fefuncb</code> <td> <code title="">feFuncB</code>
-      <tr><td> <code title="">fefuncg</code> <td> <code title="">feFuncG</code>
-      <tr><td> <code title="">fefuncr</code> <td> <code title="">feFuncR</code>
-      <tr><td> <code title="">fegaussianblur</code> <td> <code title="">feGaussianBlur</code>
-      <tr><td> <code title="">feimage</code> <td> <code title="">feImage</code>
-      <tr><td> <code title="">femerge</code> <td> <code title="">feMerge</code>
-      <tr><td> <code title="">femergenode</code> <td> <code title="">feMergeNode</code>
-      <tr><td> <code title="">femorphology</code> <td> <code title="">feMorphology</code>
-      <tr><td> <code title="">feoffset</code> <td> <code title="">feOffset</code>
-      <tr><td> <code title="">fepointlight</code> <td> <code title="">fePointLight</code>
-      <tr><td> <code title="">fespecularlighting</code> <td> <code title="">feSpecularLighting</code>
-      <tr><td> <code title="">fespotlight</code> <td> <code title="">feSpotLight</code>
-      <tr><td> <code title="">fetile</code> <td> <code title="">feTile</code>
-      <tr><td> <code title="">feturbulence</code> <td> <code title="">feTurbulence</code>
-      <tr><td> <code title="">foreignobject</code> <td> <code title="">foreignObject</code>
-      <tr><td> <code title="">glyphref</code> <td> <code title="">glyphRef</code>
-      <tr><td> <code title="">lineargradient</code> <td> <code title="">linearGradient</code>
-      <tr><td> <code title="">radialgradient</code> <td> <code title="">radialGradient</code>
-      <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
-      <tr><td> <code title="">textpath</code> <td> <code title="">textPath</code>
-    </table><p>If the <a href=#current-node>current node</a> is an element in the <a href=#svg-namespace>SVG
-    namespace</a>, <a href=#adjust-svg-attributes>adjust SVG attributes</a> for the
-    token. (This fixes the case of SVG attributes that are not all
-    lowercase.)</p>
-
-    <p><a href=#adjust-foreign-attributes>Adjust foreign attributes</a> for the token. (This
-    fixes the use of namespaced attributes, in particular XLink in
-    SVG.)</p>
-
-    <p><a href=#insert-a-foreign-element>Insert a foreign element</a> for the token, in the
-    same namespace as the <a href=#current-node>current node</a>.</p>
-
-    <p>If the token has its <i>self-closing flag</i> set, pop the
-    <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
-    elements</a> and <a href=#acknowledge-self-closing-flag title="acknowledge self-closing
-    flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
-
-   </dd>
-
-   <dt id=scriptForeignEndTag>An end tag whose tag name is "script", if the <a href=#current-node>current node</a> is a <code title="">script</code> element in the <a href=#svg-namespace>SVG namespace</a></dt>
-   <dd>
-
-    <p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
-    elements</a>.</p>
-
-    <p>Let the <var title="">old insertion point</var> have the
-    same value as the current <a href=#insertion-point>insertion point</a>. Let
-    the <a href=#insertion-point>insertion point</a> be just before the <a href=#next-input-character>next
-    input character</a>.</p>
-
-    <p>Increment the parser's <a href=#script-nesting-level>script nesting level</a> by
-    one. Set the <a href=#parser-pause-flag>parser pause flag</a> to true.</p>
-
-    <p><a href=http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing>Process
-    the <code title="">script</code> element</a> according to the SVG
-    rules, if the user agent supports SVG. <a href=#refsSVG>[SVG]</a></p>
-
-    <p class=note>Even if this causes <a href=#dom-document-write title=dom-document-write>new characters to be inserted into the
-    tokenizer</a>, the parser will not be executed reentrantly,
-    since the <a href=#parser-pause-flag>parser pause flag</a> is true.</p>
-
-    <p>Decrement the parser's <a href=#script-nesting-level>script nesting level</a> by
-    one. If the parser's <a href=#script-nesting-level>script nesting level</a> is zero,
-    then set the <a href=#parser-pause-flag>parser pause flag</a> to false.</p>
-
-    <p>Let the <a href=#insertion-point>insertion point</a> have the value of the <var title="">old insertion point</var>. (In other words, restore the
-    <a href=#insertion-point>insertion point</a> to its previous value. This value
-    might be the "undefined" value.)</p>
-
-   </dd>
-
-   <dt>Any other end tag</dt>
-
-   <dd>
-
-    <p>Run these steps:</p>
-
-    <ol><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>If <var title="">node</var> is not an element with the
-     same tag name as the token, then this is a <a href=#parse-error>parse
-     error</a>.</li>
-
-     <li><p><i>Loop</i>: If <var title="">node</var>'s tag name,
-     <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>, is the same as as the
-     tag name of the token, pop elements from the <a href=#stack-of-open-elements>stack of open
-     elements</a> until <var title="">node</var> has been popped
-     from the stack, and then jump to the last step of this list of
-     steps.</li>
-
-     <li><p>Set <var title="">node</var> to the previous entry in the
-     <a href=#stack-of-open-elements>stack of open elements</a>.</li>
-
-     <li><p>If <var title="">node</var> is not an element in the
-     <a href=#html-namespace-0>HTML namespace</a>, return to the step labeled
-     <i>loop</i>.</li>
-
-     <li><p>Otherwise, process the token <a href=#using-the-rules-for>using the rules
-     for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in
-     body</a>" <a href=#insertion-mode>insertion mode</a>, except that if those
-     rules say to reprocess the token, these steps must be finished
-     first (i.e. the insertion mode is reset by the following step
-     before the token is reprocessed).</li>
-
-     <li><p>If the <a href=#insertion-mode>insertion mode</a> is still "<a href=#parsing-main-inforeign title="insertion mode: in foreign content">in foreign
-     content</a>", <a href=#reset-the-insertion-mode-appropriately>reset the insertion mode
-     appropriately</a>.</li>
-
-    </ol></dd>
-
-  </dl><p>The <a href=#current-node>current node</a> is a <dfn id=mathml-text-integration-point>MathML text
-  integration point</dfn> if it is one of the following elements:</p>
-
-  <ul class=brief><li>An <code title="">mi</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
-   <li>An <code title="">mo</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
-   <li>An <code title="">mn</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
-   <li>An <code title="">ms</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
-   <li>An <code title="">mtext</code> element in the <a href=#mathml-namespace>MathML namespace</a></li>
-  </ul><p>The <a href=#current-node>current node</a> is an <dfn id=html-integration-point>HTML
-  integration point</dfn> if it is one of the following elements:</p>
-
-  <ul class=brief><li>An <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> whose start tag token had an attribute with the name "encoding" whose value was an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">text/html</code>"</li>
-   <li>An <code title="">annotation-xml</code> element in the <a href=#mathml-namespace>MathML namespace</a> whose start tag token had an attribute with the name "encoding" whose value was an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">application/xhtml+xml</code>"</li>
-   <li>A <code title="">foreignObject</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
-   <li>A <code title="">desc</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
-   <li>A <code title="">title</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
-  </ul><h5 id=parsing-main-afterbody><span class=secno>10.2.5.22 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h5>
-
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-afterbody title="insertion
-  mode: after body">after body</a>", tokens must be handled as follows:</p>
-
   <dl class=switch><dt>A character token that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
@@ -80139,10 +79880,9 @@
 
    </dd>
 
-  </dl><h5 id=parsing-main-inframeset><span class=secno>10.2.5.23 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-inframeset><span class=secno>10.2.5.4.19 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-inframeset title="insertion
-  mode: in frameset">in frameset</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inframeset title="insertion mode: in frameset">in frameset</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 that is one of U+0009 CHARACTER
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
@@ -80232,10 +79972,9 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
-  </dl><h5 id=parsing-main-afterframeset><span class=secno>10.2.5.24 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h5>
+  </dl><h6 id=parsing-main-afterframeset><span class=secno>10.2.5.4.20 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#parsing-main-afterframeset title="insertion
-  mode: after frameset">after frameset</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterframeset title="insertion mode: after frameset">after frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
   <dl class=switch><dt>A character token that is one of U+0009 CHARACTER
@@ -80286,10 +80025,9 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
-  </dl><h5 id=the-after-after-body-insertion-mode><span class=secno>10.2.5.25 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h5>
+  </dl><h6 id=the-after-after-body-insertion-mode><span class=secno>10.2.5.4.21 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#the-after-after-body-insertion-mode title="insertion
-  mode: after after body">after after body</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#the-after-after-body-insertion-mode title="insertion mode: after after body">after after body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A comment token</dt>
    <dd>
@@ -80320,10 +80058,9 @@
     reprocess the token.</p>
    </dd>
 
-  </dl><h5 id=the-after-after-frameset-insertion-mode><span class=secno>10.2.5.26 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h5>
+  </dl><h6 id=the-after-after-frameset-insertion-mode><span class=secno>10.2.5.4.22 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h6>
 
-  <p>When the <a href=#insertion-mode>insertion mode</a> is "<a href=#the-after-after-frameset-insertion-mode title="insertion
-  mode: after after frameset">after after frameset</a>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<a href=#the-after-after-frameset-insertion-mode title="insertion mode: after after frameset">after after frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A comment token</dt>
    <dd>
@@ -80358,6 +80095,223 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
+  </dl><h5 id=parsing-main-inforeign><span class=secno>10.2.5.5 </span>The rules for parsing tokens <dfn title="insertion mode: in foreign content">in foreign content</dfn></h5>
+
+  <p>When the user agent is to apply the rules for parsing tokens in foreign content, the user agent must handle the token as follows:</p>
+
+  <dl class=switch><dt>A character token that is U+0000 NULL</dt>
+   <dd>
+
+    <p><a href=#parse-error>Parse error</a>. <a href=#insert-a-character title="insert a
+    character">Insert a U+FFFD REPLACEMENT CHARACTER character</a>
+    into the <a href=#current-node>current node</a>.</p>
+
+   </dd>
+
+   <dt>A character token that is one of U+0009 CHARACTER TABULATION,
+   U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE
+   RETURN (CR), or U+0020 SPACE</dt>
+   <dd>
+
+    <p><a href=#insert-a-character title="insert a character">Insert the token's
+    character</a> into the <a href=#current-node>current node</a>.</p>
+
+   </dd>
+
+   <dt>Any other character token</dt>
+   <dd>
+
+    <p><a href=#insert-a-character title="insert a character">Insert the token's
+    character</a> into the <a href=#current-node>current node</a>.</p>
+
+    <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
+
+   </dd>
+
+   <dt>A comment token</dt>
+   <dd>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
+    node</a> with the <code title="">data</code> attribute set to
+    the data given in the comment token.</p>
+   </dd>
+
+   <dt>A DOCTYPE token</dt>
+   <dd>
+    <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
+   </dd>
+
+   <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
+   "blockquote", "body"<!--by inspection-->, "br", "center", "code",
+   "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
+   uniformly throughout the parser -->, "em", "embed", "h1", "h2",
+   "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
+   completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
+   "li", "listing"<!-- so that pre and listing can be handled
+   uniformly throughout the parser -->, "menu", "meta", "nobr",
+   "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
+   the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
+   "span", "strong", "strike"<!-- so that s and strike can be handled
+   uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
+   "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
+   list was determined empirically by studying over 6,000,000,000
+   pages that were specifically not XML pages -->
+   <dt>A start tag whose tag name is "font", if the token has any
+   attributes named "color", "face", or "size"</dt> <!-- the
+   attributes here are required so that SVG <font> will go through as
+   SVG but legacy <font>s won't -->
+
+   <dd>
+
+    <p><a href=#parse-error>Parse error</a>.</p>
+
+    <p>Pop an element from the <a href=#stack-of-open-elements>stack of open elements</a>,
+    and then keep popping more elements from the <a href=#stack-of-open-elements>stack of open
+    elements</a> until the <a href=#current-node>current node</a> is a
+    <a href=#mathml-text-integration-point>MathML text integration point</a>, an <a href=#html-integration-point>HTML
+    integration point</a>, or an element in the <a href=#html-namespace-0>HTML
+    namespace</a>.</p>
+
+    <p>Then, reprocess the token.</p>
+
+   </dd>
+
+   <dt>Any other start tag</dt>
+   <dd>
+
+    <p>If the <a href=#current-node>current node</a> is an element in the
+    <a href=#mathml-namespace>MathML namespace</a>, <a href=#adjust-mathml-attributes>adjust MathML
+    attributes</a> for the token. (This fixes the case of MathML
+    attributes that are not all lowercase.)</p>
+
+    <p>If the <a href=#current-node>current node</a> is an element in the <a href=#svg-namespace>SVG
+    namespace</a>, and the token's tag name is one of the ones in
+    the first column of the following table, change the tag name to
+    the name given in the corresponding cell in the second
+    column. (This fixes the case of SVG elements that are not all
+    lowercase.)</p>
+
+    <table><thead><tr><th> Tag name <th> Element name
+     <tbody><tr><td> <code title="">altglyph</code> <td> <code title="">altGlyph</code>
+      <tr><td> <code title="">altglyphdef</code> <td> <code title="">altGlyphDef</code>
+      <tr><td> <code title="">altglyphitem</code> <td> <code title="">altGlyphItem</code>
+      <tr><td> <code title="">animatecolor</code> <td> <code title="">animateColor</code>
+      <tr><td> <code title="">animatemotion</code> <td> <code title="">animateMotion</code>
+      <tr><td> <code title="">animatetransform</code> <td> <code title="">animateTransform</code>
+      <tr><td> <code title="">clippath</code> <td> <code title="">clipPath</code>
+      <tr><td> <code title="">feblend</code> <td> <code title="">feBlend</code>
+      <tr><td> <code title="">fecolormatrix</code> <td> <code title="">feColorMatrix</code>
+      <tr><td> <code title="">fecomponenttransfer</code> <td> <code title="">feComponentTransfer</code>
+      <tr><td> <code title="">fecomposite</code> <td> <code title="">feComposite</code>
+      <tr><td> <code title="">feconvolvematrix</code> <td> <code title="">feConvolveMatrix</code>
+      <tr><td> <code title="">fediffuselighting</code> <td> <code title="">feDiffuseLighting</code>
+      <tr><td> <code title="">fedisplacementmap</code> <td> <code title="">feDisplacementMap</code>
+      <tr><td> <code title="">fedistantlight</code> <td> <code title="">feDistantLight</code>
+      <tr><td> <code title="">feflood</code> <td> <code title="">feFlood</code>
+      <tr><td> <code title="">fefunca</code> <td> <code title="">feFuncA</code>
+      <tr><td> <code title="">fefuncb</code> <td> <code title="">feFuncB</code>
+      <tr><td> <code title="">fefuncg</code> <td> <code title="">feFuncG</code>
+      <tr><td> <code title="">fefuncr</code> <td> <code title="">feFuncR</code>
+      <tr><td> <code title="">fegaussianblur</code> <td> <code title="">feGaussianBlur</code>
+      <tr><td> <code title="">feimage</code> <td> <code title="">feImage</code>
+      <tr><td> <code title="">femerge</code> <td> <code title="">feMerge</code>
+      <tr><td> <code title="">femergenode</code> <td> <code title="">feMergeNode</code>
+      <tr><td> <code title="">femorphology</code> <td> <code title="">feMorphology</code>
+      <tr><td> <code title="">feoffset</code> <td> <code title="">feOffset</code>
+      <tr><td> <code title="">fepointlight</code> <td> <code title="">fePointLight</code>
+      <tr><td> <code title="">fespecularlighting</code> <td> <code title="">feSpecularLighting</code>
+      <tr><td> <code title="">fespotlight</code> <td> <code title="">feSpotLight</code>
+      <tr><td> <code title="">fetile</code> <td> <code title="">feTile</code>
+      <tr><td> <code title="">feturbulence</code> <td> <code title="">feTurbulence</code>
+      <tr><td> <code title="">foreignobject</code> <td> <code title="">foreignObject</code>
+      <tr><td> <code title="">glyphref</code> <td> <code title="">glyphRef</code>
+      <tr><td> <code title="">lineargradient</code> <td> <code title="">linearGradient</code>
+      <tr><td> <code title="">radialgradient</code> <td> <code title="">radialGradient</code>
+      <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
+      <tr><td> <code title="">textpath</code> <td> <code title="">textPath</code>
+    </table><p>If the <a href=#current-node>current node</a> is an element in the <a href=#svg-namespace>SVG
+    namespace</a>, <a href=#adjust-svg-attributes>adjust SVG attributes</a> for the
+    token. (This fixes the case of SVG attributes that are not all
+    lowercase.)</p>
+
+    <p><a href=#adjust-foreign-attributes>Adjust foreign attributes</a> for the token. (This
+    fixes the use of namespaced attributes, in particular XLink in
+    SVG.)</p>
+
+    <p><a href=#insert-a-foreign-element>Insert a foreign element</a> for the token, in the
+    same namespace as the <a href=#current-node>current node</a>.</p>
+
+    <p>If the token has its <i>self-closing flag</i> set, pop the
+    <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
+    elements</a> and <a href=#acknowledge-self-closing-flag title="acknowledge self-closing
+    flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
+
+   </dd>
+
+   <dt id=scriptForeignEndTag>An end tag whose tag name is "script", if the <a href=#current-node>current node</a> is a <code title="">script</code> element in the <a href=#svg-namespace>SVG namespace</a></dt>
+   <dd>
+
+    <p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
+    elements</a>.</p>
+
+    <p>Let the <var title="">old insertion point</var> have the
+    same value as the current <a href=#insertion-point>insertion point</a>. Let
+    the <a href=#insertion-point>insertion point</a> be just before the <a href=#next-input-character>next
+    input character</a>.</p>
+
+    <p>Increment the parser's <a href=#script-nesting-level>script nesting level</a> by
+    one. Set the <a href=#parser-pause-flag>parser pause flag</a> to true.</p>
+
+    <p><a href=http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing>Process
+    the <code title="">script</code> element</a> according to the SVG
+    rules, if the user agent supports SVG. <a href=#refsSVG>[SVG]</a></p>
+
+    <p class=note>Even if this causes <a href=#dom-document-write title=dom-document-write>new characters to be inserted into the
+    tokenizer</a>, the parser will not be executed reentrantly,
+    since the <a href=#parser-pause-flag>parser pause flag</a> is true.</p>
+
+    <p>Decrement the parser's <a href=#script-nesting-level>script nesting level</a> by
+    one. If the parser's <a href=#script-nesting-level>script nesting level</a> is zero,
+    then set the <a href=#parser-pause-flag>parser pause flag</a> to false.</p>
+
+    <p>Let the <a href=#insertion-point>insertion point</a> have the value of the <var title="">old insertion point</var>. (In other words, restore the
+    <a href=#insertion-point>insertion point</a> to its previous value. This value
+    might be the "undefined" value.)</p>
+
+   </dd>
+
+   <dt>Any other end tag</dt>
+
+   <dd>
+
+    <p>Run these steps:</p>
+
+    <ol><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>If <var title="">node</var> is not an element with the
+     same tag name as the token, then this is a <a href=#parse-error>parse
+     error</a>.</li>
+
+     <li><p><i>Loop</i>: If <var title="">node</var>'s tag name,
+     <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>, is the same as as the
+     tag name of the token, pop elements from the <a href=#stack-of-open-elements>stack of open
+     elements</a> until <var title="">node</var> has been popped
+     from the stack, and then jump to the last step of this list of
+     steps.</li>
+
+     <li><p>Set <var title="">node</var> to the previous entry in the
+     <a href=#stack-of-open-elements>stack of open elements</a>.</li>
+
+     <li><p>If <var title="">node</var> is not an element in the
+     <a href=#html-namespace-0>HTML namespace</a>, return to the step labeled
+     <i>loop</i>.</li>
+
+     <li><p>Otherwise, process the token according to the rules given
+     in the section corresponding to the current <a href=#insertion-mode>insertion
+     mode</a> in HTML content.</li>
+
+    </ol></dd>
+
   </dl></div>
 
 

Modified: source
===================================================================
--- source	2011-02-27 00:03:26 UTC (rev 5919)
+++ source	2011-02-28 23:56:22 UTC (rev 5920)
@@ -88307,18 +88307,16 @@
   title="insertion mode: in head noscript">in head noscript</span>",
   "<span title="insertion mode: after head">after head</span>", "<span
   title="insertion mode: in body">in body</span>", "<span
-  title="insertion mode: text">text</span>",
-  "<span title="insertion mode: in table">in table</span>", "<span
-  title="insertion mode: in table text">in table text</span>", "<span
-  title="insertion mode: in caption">in caption</span>", "<span
-  title="insertion mode: in column group">in column group</span>",
-  "<span title="insertion mode: in table body">in table body</span>",
-  "<span title="insertion mode: in row">in row</span>", "<span
-  title="insertion mode: in cell">in cell</span>", "<span
-  title="insertion mode: in select">in select</span>", "<span
-  title="insertion mode: in select in table">in select in
-  table</span>", "<span title="insertion mode: in foreign content">in
-  foreign content</span>", "<span title="insertion mode: after
+  title="insertion mode: text">text</span>", "<span title="insertion
+  mode: in table">in table</span>", "<span title="insertion mode: in
+  table text">in table text</span>", "<span title="insertion mode: in
+  caption">in caption</span>", "<span title="insertion mode: in column
+  group">in column group</span>", "<span title="insertion mode: in
+  table body">in table body</span>", "<span title="insertion mode: in
+  row">in row</span>", "<span title="insertion mode: in cell">in
+  cell</span>", "<span title="insertion mode: in select">in
+  select</span>", "<span title="insertion mode: in select in table">in
+  select in table</span>", "<span title="insertion mode: after
   body">after body</span>", "<span title="insertion mode: in
   frameset">in frameset</span>", "<span title="insertion mode: after
   frameset">after frameset</span>", "<span title="insertion mode:
@@ -88439,12 +88437,6 @@
    non-null when we're going through these steps, we'll need to
    uncomment out the commented-out bits -->
 
-   <li>If <var title="">node</var> is an element from the <span>MathML
-   namespace</span> or the <span>SVG namespace</span>, then switch the
-   <span>insertion mode</span> to "<span title="insertion mode: in
-   foreign content">in foreign content</span>" and abort these
-   steps.</li>
-
    <li>If <var title="">last</var> is true, then switch the
    <span>insertion mode</span> to "<span title="insertion mode: in
    body">in body</span>" and abort these steps. (<span>fragment
@@ -90312,12 +90304,10 @@
   case-insensitive</span> match for the word "DOCTYPE", then consume
   those characters and switch to the <span>DOCTYPE state</span>.</p>
 
-  <p>Otherwise, if the <span>insertion mode</span> is "<span
-  title="insertion mode: in foreign content">in foreign
-  content</span>" and the <span>current node</span> is not an element
-  in the <span>HTML namespace</span> and the next seven characters are
-  an <span>case-sensitive</span> match for the string "[CDATA[" (the
-  five uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
+  <p>Otherwise, if the <span>current node</span> is not an element in
+  the <span>HTML namespace</span> and the next seven characters are an
+  <span>case-sensitive</span> match for the string "[CDATA[" (the five
+  uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
   character before and after), then consume those characters and
   switch to the <span>CDATA section state</span>.</p>
 
@@ -91344,10 +91334,57 @@
   has to render the <code>Document</code> so that it is available to
   the user, or when it has to begin accepting user input.</p>
 
+  <hr>
+
   <p>As each token is emitted from the tokenizer, the user agent must
-  process the token according to the rules given in the section
-  corresponding to the current <span>insertion mode</span>.</p>
+  follow the appropriate steps from the following list:</p>
 
+  <dl class="switch">
+
+   <dt>If there is no <span>current node</span></dt>
+   <dt>If the <span>current node</span> is an element in the <span>HTML namespace</span></dt>
+   <dt>If the <span>current node</span> is a <span>MathML text integration point</span> and the token is a start tag whose tag name is neither "mglyph" nor "malignmark"</dt>
+   <dt>If the <span>current node</span> is an <code title="">annotation-xml</code> element in the <span>MathML namespace</span> and the token is a start tag whose tag name is "svg"</dt>
+   <dt>If the <span>current node</span> is an <span>HTML integration point</span> and the token is a start tag</dt>
+   <dt>If the <span>current node</span> is an <span>HTML integration point</span> and the token is a character token</dt>
+   <dt>If the token is an end-of-file token</dt>
+
+   <dd>Process the token according to the rules given in the section
+   corresponding to the current <span>insertion mode</span> in HTML
+   content.</dd>
+
+   <dt>Otherwise</dt>
+
+   <dd>Process the token according to the rules given in the section
+   for parsing tokens <span title="insertion mode: in foreign
+   content">in foreign content</span>.</dd>
+
+  </dl>
+
+  <p>The <span>current node</span> is a <dfn>MathML text
+  integration point</dfn> if it is one of the following elements:</p>
+
+  <ul class="brief">
+   <li>An <code title="">mi</code> element in the <span>MathML namespace</span></li>
+   <li>An <code title="">mo</code> element in the <span>MathML namespace</span></li>
+   <li>An <code title="">mn</code> element in the <span>MathML namespace</span></li>
+   <li>An <code title="">ms</code> element in the <span>MathML namespace</span></li>
+   <li>An <code title="">mtext</code> element in the <span>MathML namespace</span></li>
+  </ul>
+
+  <p>The <span>current node</span> is an <dfn>HTML
+  integration point</dfn> if it is one of the following elements:</p>
+
+  <ul class="brief">
+   <li>An <code title="">annotation-xml</code> element in the <span>MathML namespace</span> whose start tag token had an attribute with the name "encoding" whose value was an <span>ASCII case-insensitive</span> match for the string "<code title="">text/html</code>"</li>
+   <li>An <code title="">annotation-xml</code> element in the <span>MathML namespace</span> whose start tag token had an attribute with the name "encoding" whose value was an <span>ASCII case-insensitive</span> match for the string "<code title="">application/xhtml+xml</code>"</li>
+   <li>A <code title="">foreignObject</code> element in the <span>SVG namespace</span></li>
+   <li>A <code title="">desc</code> element in the <span>SVG namespace</span></li>
+   <li>A <code title="">title</code> element in the <span>SVG namespace</span></li>
+  </ul>
+
+  <hr>
+
   <p>When the steps below require the UA to <dfn>insert a
   character</dfn> into a node, if that node has a child immediately
   before where the character is to be inserted, and that child is a
@@ -91683,11 +91720,13 @@
 
 
 
-  <h5>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h5>
+  <h5 id="parsing-main-inhtml">The rules for parsing tokens in HTML content</h5>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: initial">initial</span>", tokens must be handled as follows:</p>
 
+  <h6>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h6>
+
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: initial">initial</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
+
   <dl class="switch">
 
    <dt>A character token that is one of U+0009 CHARACTER
@@ -91902,10 +91941,9 @@
   </dl>
 
 
-  <h5>The "<dfn title="insertion mode: before html">before html</dfn>" insertion mode</h5>
+  <h6>The "<dfn title="insertion mode: before html">before html</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: before html">before html</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: before html">before html</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -91996,10 +92034,9 @@
   as described in the next section.</p>
 
 
-  <h5>The "<dfn title="insertion mode: before head">before head</dfn>" insertion mode</h5>
+  <h6>The "<dfn title="insertion mode: before head">before head</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: before head">before head</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: before head">before head</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -92069,10 +92106,9 @@
   </dl>
 
 
-  <h5 id="parsing-main-inhead">The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-inhead">The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in head">in head</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in head">in head</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -92254,10 +92290,9 @@
   </dl>
 
 
-  <h5 id="parsing-main-inheadnoscript">The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-inheadnoscript">The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in head noscript">in head noscript</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in head noscript">in head noscript</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -92323,10 +92358,9 @@
   </dl>
 
 
-  <h5>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h5>
+  <h6>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: after head">after head</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: after head">after head</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -92425,10 +92459,9 @@
   </dl>
 
 
-  <h5 id="parsing-main-inbody">The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-inbody">The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in body">in body</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in body">in body</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -93675,12 +93708,6 @@
     elements</span> and <span title="acknowledge self-closing
     flag">acknowledge the token's <i>self-closing flag</i></span>.</p>
 
-    <p>Otherwise, if the <span>insertion mode</span> is not already
-    "<span title="insertion mode: in foreign content">in foreign
-    content</span>", switch the <span>insertion mode</span> to "<span
-    title="insertion mode: in foreign content">in foreign
-    content</span>".</p>
-
    </dd>
 
    <dt>A start tag whose tag name is "svg"</dt>
@@ -93710,12 +93737,6 @@
     elements</span> and <span title="acknowledge self-closing
     flag">acknowledge the token's <i>self-closing flag</i></span>.</p>
 
-    <p>Otherwise, if the <span>insertion mode</span> is not already
-    "<span title="insertion mode: in foreign content">in foreign
-    content</span>", switch the <span>insertion mode</span> to "<span
-    title="insertion mode: in foreign content">in foreign
-    content</span>".</p>
-
    </dd>
 
    <dt>A start <!--or end--> tag whose tag name is one of: "caption",
@@ -93797,10 +93818,9 @@
 
 
 
-  <h5 id="parsing-main-incdata">The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-incdata">The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: text">text</span>", tokens must be handled as follows:</p>
+  <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>
 
   <dl class="switch">
 
@@ -93970,10 +93990,9 @@
   </dl>
 
 
-  <h5 id="parsing-main-intable">The "<dfn title="insertion mode: in table">in table</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-intable">The "<dfn title="insertion mode: in table">in table</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in table">in table</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in table">in table</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -94186,11 +94205,9 @@
 
 
 
-  <h5 id="parsing-main-intabletext">The "<dfn title="insertion mode: in table text">in table text</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-intabletext">The "<dfn title="insertion mode: in table text">in table text</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in table text">in table text</span>", tokens must be handled
-  as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in table text">in table text</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -94234,10 +94251,9 @@
   </dl>
 
 
-  <h5 id="parsing-main-incaption">The "<dfn title="insertion mode: in caption">in caption</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-incaption">The "<dfn title="insertion mode: in caption">in caption</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in caption">in caption</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in caption">in caption</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -94300,10 +94316,9 @@
   </dl>
 
 
-  <h5 id="parsing-main-incolgroup">The "<dfn title="insertion mode: in column group">in column group</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-incolgroup">The "<dfn title="insertion mode: in column group">in column group</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in column group">in column group</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in column group">in column group</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -94393,10 +94408,9 @@
   </dl>
 
 
-  <h5 id="parsing-main-intbody">The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-intbody">The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in table body">in table body</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in table body">in table body</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -94489,10 +94503,9 @@
   case</span>.</p>
 
 
-  <h5 id="parsing-main-intr">The "<dfn title="insertion mode: in row">in row</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-intr">The "<dfn title="insertion mode: in row">in row</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in row">in row</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in row">in row</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -94587,10 +94600,9 @@
   case</span>.</p>
 
 
-  <h5 id="parsing-main-intd">The "<dfn title="insertion mode: in cell">in cell</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-intd">The "<dfn title="insertion mode: in cell">in cell</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in cell">in cell</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in cell">in cell</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -94695,10 +94707,9 @@
   cell</span> algorithm is invoked.</p>
 
 
-  <h5 id="parsing-main-inselect">The "<dfn title="insertion mode: in select">in select</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-inselect">The "<dfn title="insertion mode: in select">in select</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in select">in select</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in select">in select</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -94855,10 +94866,9 @@
   </dl>
 
 
-  <h5 id="parsing-main-inselectintable">The "<dfn title="insertion mode: in select in table">in select in table</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-inselectintable">The "<dfn title="insertion mode: in select in table">in select in table</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in select in table">in select in table</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in select in table">in select in table</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -94893,306 +94903,11 @@
   </dl>
 
 
-  <h5 id="parsing-main-inforeign">The "<dfn title="insertion mode: in foreign content">in foreign content</dfn>" insertion mode</h5>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in foreign content">in foreign content</span>", tokens must be
-  handled as follows:</p>
+  <h6 id="parsing-main-afterbody">The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6>
 
-  <dl class="switch">
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: after body">after body</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
-   <dt>Any token, if the <span>current node</span> is an element in the <span>HTML namespace</span></dt>
-   <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <span>current node</span> is a <span>MathML text integration point</span></dt>
-   <dt>A start tag whose tag name is "svg", if the <span>current node</span> is an <code title="">annotation-xml</code> element in the <span>MathML namespace</span></dt>
-   <dt>A start tag, if the <span>current node</span> is an <span>HTML integration point</span></dt>
-   <dt>A character token, if the <span>current node</span> is an <span>HTML integration point</span></dt>
-   <dt>An end-of-file token</dt>
-   <dd>
-
-    <ol>
-
-     <li><p>Process the token <span>using the rules for</span> the
-     "<span title="insertion mode: in body">in body</span>"
-     <span>insertion mode</span>, except that if those rules say to
-     reprocess the token, these steps must be finished first (i.e. the
-     insertion mode is reset by the following step before the token is
-     reprocessed).</p></li>
-
-     <li><p>If, after doing so, the <span>insertion mode</span> is
-     still "<span title="insertion mode: in foreign content">in
-     foreign content</span>", <span>reset the insertion mode
-     appropriately</span>.</p></li>
-
-    </ol>
-
-   </dd>
-
-   <dt>A character token that is U+0000 NULL</dt>
-   <dd>
-
-    <p><span>Parse error</span>. <span title="insert a
-    character">Insert a U+FFFD REPLACEMENT CHARACTER character</span>
-    into the <span>current node</span>.</p>
-
-   </dd>
-
-   <dt>A character token that is one of U+0009 CHARACTER TABULATION,
-   U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE
-   RETURN (CR), or U+0020 SPACE</dt>
-   <dd>
-
-    <p><span title="insert a character">Insert the token's
-    character</span> into the <span>current node</span>.</p>
-
-   </dd>
-
-   <dt>Any other character token</dt>
-   <dd>
-
-    <p><span title="insert a character">Insert the token's
-    character</span> into the <span>current node</span>.</p>
-
-    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
-
-   </dd>
-
-   <dt>A comment token</dt>
-   <dd>
-    <p>Append a <code>Comment</code> node to the <span>current
-    node</span> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
-   </dd>
-
-   <dt>A DOCTYPE token</dt>
-   <dd>
-    <p><span>Parse error</span>. Ignore the token.</p>
-   </dd>
-
-   <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
-   "blockquote", "body"<!--by inspection-->, "br", "center", "code",
-   "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
-   uniformly throughout the parser -->, "em", "embed", "h1", "h2",
-   "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
-   completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
-   "li", "listing"<!-- so that pre and listing can be handled
-   uniformly throughout the parser -->, "menu", "meta", "nobr",
-   "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
-   the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
-   "span", "strong", "strike"<!-- so that s and strike can be handled
-   uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
-   "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
-   list was determined empirically by studying over 6,000,000,000
-   pages that were specifically not XML pages -->
-   <dt>A start tag whose tag name is "font", if the token has any
-   attributes named "color", "face", or "size"</dt> <!-- the
-   attributes here are required so that SVG <font> will go through as
-   SVG but legacy <font>s won't -->
-
-   <dd>
-
-    <p><span>Parse error</span>.</p>
-
-    <p>Pop an element from the <span>stack of open elements</span>,
-    and then keep popping more elements from the <span>stack of open
-    elements</span> until the <span>current node</span> is a
-    <span>MathML text integration point</span>, an <span>HTML
-    integration point</span>, or an element in the <span>HTML
-    namespace</span>.</p>
-
-    <p>Then, <span>reset the insertion mode appropriately</span> and
-    reprocess the token.</p>
-
-   </dd>
-
-   <dt>Any other start tag</dt>
-   <dd>
-
-    <p>If the <span>current node</span> is an element in the
-    <span>MathML namespace</span>, <span>adjust MathML
-    attributes</span> for the token. (This fixes the case of MathML
-    attributes that are not all lowercase.)</p>
-
-    <p>If the <span>current node</span> is an element in the <span>SVG
-    namespace</span>, and the token's tag name is one of the ones in
-    the first column of the following table, change the tag name to
-    the name given in the corresponding cell in the second
-    column. (This fixes the case of SVG elements that are not all
-    lowercase.)</p>
-
-    <table>
-     <thead>
-      <tr> <th> Tag name <th> Element name
-     <tbody>
-      <tr> <td> <code title="">altglyph</code> <td> <code title="">altGlyph</code>
-      <tr> <td> <code title="">altglyphdef</code> <td> <code title="">altGlyphDef</code>
-      <tr> <td> <code title="">altglyphitem</code> <td> <code title="">altGlyphItem</code>
-      <tr> <td> <code title="">animatecolor</code> <td> <code title="">animateColor</code>
-      <tr> <td> <code title="">animatemotion</code> <td> <code title="">animateMotion</code>
-      <tr> <td> <code title="">animatetransform</code> <td> <code title="">animateTransform</code>
-      <tr> <td> <code title="">clippath</code> <td> <code title="">clipPath</code>
-      <tr> <td> <code title="">feblend</code> <td> <code title="">feBlend</code>
-      <tr> <td> <code title="">fecolormatrix</code> <td> <code title="">feColorMatrix</code>
-      <tr> <td> <code title="">fecomponenttransfer</code> <td> <code title="">feComponentTransfer</code>
-      <tr> <td> <code title="">fecomposite</code> <td> <code title="">feComposite</code>
-      <tr> <td> <code title="">feconvolvematrix</code> <td> <code title="">feConvolveMatrix</code>
-      <tr> <td> <code title="">fediffuselighting</code> <td> <code title="">feDiffuseLighting</code>
-      <tr> <td> <code title="">fedisplacementmap</code> <td> <code title="">feDisplacementMap</code>
-      <tr> <td> <code title="">fedistantlight</code> <td> <code title="">feDistantLight</code>
-      <tr> <td> <code title="">feflood</code> <td> <code title="">feFlood</code>
-      <tr> <td> <code title="">fefunca</code> <td> <code title="">feFuncA</code>
-      <tr> <td> <code title="">fefuncb</code> <td> <code title="">feFuncB</code>
-      <tr> <td> <code title="">fefuncg</code> <td> <code title="">feFuncG</code>
-      <tr> <td> <code title="">fefuncr</code> <td> <code title="">feFuncR</code>
-      <tr> <td> <code title="">fegaussianblur</code> <td> <code title="">feGaussianBlur</code>
-      <tr> <td> <code title="">feimage</code> <td> <code title="">feImage</code>
-      <tr> <td> <code title="">femerge</code> <td> <code title="">feMerge</code>
-      <tr> <td> <code title="">femergenode</code> <td> <code title="">feMergeNode</code>
-      <tr> <td> <code title="">femorphology</code> <td> <code title="">feMorphology</code>
-      <tr> <td> <code title="">feoffset</code> <td> <code title="">feOffset</code>
-      <tr> <td> <code title="">fepointlight</code> <td> <code title="">fePointLight</code>
-      <tr> <td> <code title="">fespecularlighting</code> <td> <code title="">feSpecularLighting</code>
-      <tr> <td> <code title="">fespotlight</code> <td> <code title="">feSpotLight</code>
-      <tr> <td> <code title="">fetile</code> <td> <code title="">feTile</code>
-      <tr> <td> <code title="">feturbulence</code> <td> <code title="">feTurbulence</code>
-      <tr> <td> <code title="">foreignobject</code> <td> <code title="">foreignObject</code>
-      <tr> <td> <code title="">glyphref</code> <td> <code title="">glyphRef</code>
-      <tr> <td> <code title="">lineargradient</code> <td> <code title="">linearGradient</code>
-      <tr> <td> <code title="">radialgradient</code> <td> <code title="">radialGradient</code>
-      <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
-      <tr> <td> <code title="">textpath</code> <td> <code title="">textPath</code>
-    </table>
-
-    <p>If the <span>current node</span> is an element in the <span>SVG
-    namespace</span>, <span>adjust SVG attributes</span> for the
-    token. (This fixes the case of SVG attributes that are not all
-    lowercase.)</p>
-
-    <p><span>Adjust foreign attributes</span> for the token. (This
-    fixes the use of namespaced attributes, in particular XLink in
-    SVG.)</p>
-
-    <p><span>Insert a foreign element</span> for the token, in the
-    same namespace as the <span>current node</span>.</p>
-
-    <p>If the token has its <i>self-closing flag</i> set, pop the
-    <span>current node</span> off the <span>stack of open
-    elements</span> and <span title="acknowledge self-closing
-    flag">acknowledge the token's <i>self-closing flag</i></span>.</p>
-
-   </dd>
-
-   <dt id="scriptForeignEndTag">An end tag whose tag name is "script", if the <span>current node</span> is a <code title="">script</code> element in the <span>SVG namespace</span></dt>
-   <dd>
-
-    <p>Pop the <span>current node</span> off the <span>stack of open
-    elements</span>.</p>
-
-    <p>Let the <var title="">old insertion point</var> have the
-    same value as the current <span>insertion point</span>. Let
-    the <span>insertion point</span> be just before the <span>next
-    input character</span>.</p>
-
-    <p>Increment the parser's <span>script nesting level</span> by
-    one. Set the <span>parser pause flag</span> to true.</p>
-
-    <p><a
-    href="http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process
-    the <code title="">script</code> element</a> according to the SVG
-    rules, if the user agent supports SVG. <a
-    href="#refsSVG">[SVG]</a></p>
-
-    <p class="note">Even if this causes <span
-    title="dom-document-write">new characters to be inserted into the
-    tokenizer</span>, the parser will not be executed reentrantly,
-    since the <span>parser pause flag</span> is true.</p>
-
-    <p>Decrement the parser's <span>script nesting level</span> by
-    one. If the parser's <span>script nesting level</span> is zero,
-    then set the <span>parser pause flag</span> to false.</p>
-
-    <p>Let the <span>insertion point</span> have the value of the <var
-    title="">old insertion point</var>. (In other words, restore the
-    <span>insertion point</span> to its previous value. This value
-    might be the "undefined" value.)</p>
-
-   </dd>
-
-   <dt>Any other end tag</dt>
-
-   <dd>
-
-    <p>Run these steps:</p>
-
-    <ol>
-
-     <li><p>Initialize <var title="">node</var> to be the <span>current
-     node</span> (the bottommost node of the stack).</p></li>
-
-     <li><p>If <var title="">node</var> is not an element with the
-     same tag name as the token, then this is a <span>parse
-     error</span>.</p></li>
-
-     <li><p><i>Loop</i>: If <var title="">node</var>'s tag name,
-     <span>converted to ASCII lowercase</span>, is the same as as the
-     tag name of the token, pop elements from the <span>stack of open
-     elements</span> until <var title="">node</var> has been popped
-     from the stack, and then jump to the last step of this list of
-     steps.</p></li>
-
-     <li><p>Set <var title="">node</var> to the previous entry in the
-     <span>stack of open elements</span>.</p></li>
-
-     <li><p>If <var title="">node</var> is not an element in the
-     <span>HTML namespace</span>, return to the step labeled
-     <i>loop</i>.</p></li>
-
-     <li><p>Otherwise, process the token <span>using the rules
-     for</span> the "<span title="insertion mode: in body">in
-     body</span>" <span>insertion mode</span>, except that if those
-     rules say to reprocess the token, these steps must be finished
-     first (i.e. the insertion mode is reset by the following step
-     before the token is reprocessed).</p></li>
-
-     <li><p>If the <span>insertion mode</span> is still "<span
-     title="insertion mode: in foreign content">in foreign
-     content</span>", <span>reset the insertion mode
-     appropriately</span>.</p></li>
-
-    </ol>
-
-   </dd>
-
-  </dl>
-
-  <p>The <span>current node</span> is a <dfn>MathML text
-  integration point</dfn> if it is one of the following elements:</p>
-
-  <ul class="brief">
-   <li>An <code title="">mi</code> element in the <span>MathML namespace</span></li>
-   <li>An <code title="">mo</code> element in the <span>MathML namespace</span></li>
-   <li>An <code title="">mn</code> element in the <span>MathML namespace</span></li>
-   <li>An <code title="">ms</code> element in the <span>MathML namespace</span></li>
-   <li>An <code title="">mtext</code> element in the <span>MathML namespace</span></li>
-  </ul>
-
-  <p>The <span>current node</span> is an <dfn>HTML
-  integration point</dfn> if it is one of the following elements:</p>
-
-  <ul class="brief">
-   <li>An <code title="">annotation-xml</code> element in the <span>MathML namespace</span> whose start tag token had an attribute with the name "encoding" whose value was an <span>ASCII case-insensitive</span> match for the string "<code title="">text/html</code>"</li>
-   <li>An <code title="">annotation-xml</code> element in the <span>MathML namespace</span> whose start tag token had an attribute with the name "encoding" whose value was an <span>ASCII case-insensitive</span> match for the string "<code title="">application/xhtml+xml</code>"</li>
-   <li>A <code title="">foreignObject</code> element in the <span>SVG namespace</span></li>
-   <li>A <code title="">desc</code> element in the <span>SVG namespace</span></li>
-   <li>A <code title="">title</code> element in the <span>SVG namespace</span></li>
-  </ul>
-
-
-
-  <h5 id="parsing-main-afterbody">The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h5>
-
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: after body">after body</span>", tokens must be handled as follows:</p>
-
   <dl class="switch">
 
    <dt>A character token that is one of U+0009 CHARACTER
@@ -95254,10 +94969,9 @@
   </dl>
 
 
-  <h5 id="parsing-main-inframeset">The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-inframeset">The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: in frameset">in frameset</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in frameset">in frameset</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -95355,10 +95069,9 @@
   </dl>
 
 
-  <h5 id="parsing-main-afterframeset">The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h5>
+  <h6 id="parsing-main-afterframeset">The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: after frameset">after frameset</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: after frameset">after frameset</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
   <dl class="switch">
@@ -95417,10 +95130,9 @@
   </dl>
 
 
-  <h5>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h5>
+  <h6>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: after after body">after after body</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: after after body">after after body</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -95457,10 +95169,9 @@
   </dl>
 
 
-  <h5>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h5>
+  <h6>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h6>
 
-  <p>When the <span>insertion mode</span> is "<span title="insertion
-  mode: after after frameset">after after frameset</span>", tokens must be handled as follows:</p>
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: after after frameset">after after frameset</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
 
   <dl class="switch">
 
@@ -95501,6 +95212,242 @@
 
   </dl>
 
+
+
+  <h5 id="parsing-main-inforeign">The rules for parsing tokens <dfn title="insertion mode: in foreign content">in foreign content</dfn></h5>
+
+  <p>When the user agent is to apply the rules for parsing tokens in foreign content, the user agent must handle the token as follows:</p>
+
+  <dl class="switch">
+
+   <dt>A character token that is U+0000 NULL</dt>
+   <dd>
+
+    <p><span>Parse error</span>. <span title="insert a
+    character">Insert a U+FFFD REPLACEMENT CHARACTER character</span>
+    into the <span>current node</span>.</p>
+
+   </dd>
+
+   <dt>A character token that is one of U+0009 CHARACTER TABULATION,
+   U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE
+   RETURN (CR), or U+0020 SPACE</dt>
+   <dd>
+
+    <p><span title="insert a character">Insert the token's
+    character</span> into the <span>current node</span>.</p>
+
+   </dd>
+
+   <dt>Any other character token</dt>
+   <dd>
+
+    <p><span title="insert a character">Insert the token's
+    character</span> into the <span>current node</span>.</p>
+
+    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
+
+   </dd>
+
+   <dt>A comment token</dt>
+   <dd>
+    <p>Append a <code>Comment</code> node to the <span>current
+    node</span> with the <code title="">data</code> attribute set to
+    the data given in the comment token.</p>
+   </dd>
+
+   <dt>A DOCTYPE token</dt>
+   <dd>
+    <p><span>Parse error</span>. Ignore the token.</p>
+   </dd>
+
+   <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
+   "blockquote", "body"<!--by inspection-->, "br", "center", "code",
+   "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
+   uniformly throughout the parser -->, "em", "embed", "h1", "h2",
+   "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
+   completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
+   "li", "listing"<!-- so that pre and listing can be handled
+   uniformly throughout the parser -->, "menu", "meta", "nobr",
+   "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
+   the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
+   "span", "strong", "strike"<!-- so that s and strike can be handled
+   uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
+   "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
+   list was determined empirically by studying over 6,000,000,000
+   pages that were specifically not XML pages -->
+   <dt>A start tag whose tag name is "font", if the token has any
+   attributes named "color", "face", or "size"</dt> <!-- the
+   attributes here are required so that SVG <font> will go through as
+   SVG but legacy <font>s won't -->
+
+   <dd>
+
+    <p><span>Parse error</span>.</p>
+
+    <p>Pop an element from the <span>stack of open elements</span>,
+    and then keep popping more elements from the <span>stack of open
+    elements</span> until the <span>current node</span> is a
+    <span>MathML text integration point</span>, an <span>HTML
+    integration point</span>, or an element in the <span>HTML
+    namespace</span>.</p>
+
+    <p>Then, reprocess the token.</p>
+
+   </dd>
+
+   <dt>Any other start tag</dt>
+   <dd>
+
+    <p>If the <span>current node</span> is an element in the
+    <span>MathML namespace</span>, <span>adjust MathML
+    attributes</span> for the token. (This fixes the case of MathML
+    attributes that are not all lowercase.)</p>
+
+    <p>If the <span>current node</span> is an element in the <span>SVG
+    namespace</span>, and the token's tag name is one of the ones in
+    the first column of the following table, change the tag name to
+    the name given in the corresponding cell in the second
+    column. (This fixes the case of SVG elements that are not all
+    lowercase.)</p>
+
+    <table>
+     <thead>
+      <tr> <th> Tag name <th> Element name
+     <tbody>
+      <tr> <td> <code title="">altglyph</code> <td> <code title="">altGlyph</code>
+      <tr> <td> <code title="">altglyphdef</code> <td> <code title="">altGlyphDef</code>
+      <tr> <td> <code title="">altglyphitem</code> <td> <code title="">altGlyphItem</code>
+      <tr> <td> <code title="">animatecolor</code> <td> <code title="">animateColor</code>
+      <tr> <td> <code title="">animatemotion</code> <td> <code title="">animateMotion</code>
+      <tr> <td> <code title="">animatetransform</code> <td> <code title="">animateTransform</code>
+      <tr> <td> <code title="">clippath</code> <td> <code title="">clipPath</code>
+      <tr> <td> <code title="">feblend</code> <td> <code title="">feBlend</code>
+      <tr> <td> <code title="">fecolormatrix</code> <td> <code title="">feColorMatrix</code>
+      <tr> <td> <code title="">fecomponenttransfer</code> <td> <code title="">feComponentTransfer</code>
+      <tr> <td> <code title="">fecomposite</code> <td> <code title="">feComposite</code>
+      <tr> <td> <code title="">feconvolvematrix</code> <td> <code title="">feConvolveMatrix</code>
+      <tr> <td> <code title="">fediffuselighting</code> <td> <code title="">feDiffuseLighting</code>
+      <tr> <td> <code title="">fedisplacementmap</code> <td> <code title="">feDisplacementMap</code>
+      <tr> <td> <code title="">fedistantlight</code> <td> <code title="">feDistantLight</code>
+      <tr> <td> <code title="">feflood</code> <td> <code title="">feFlood</code>
+      <tr> <td> <code title="">fefunca</code> <td> <code title="">feFuncA</code>
+      <tr> <td> <code title="">fefuncb</code> <td> <code title="">feFuncB</code>
+      <tr> <td> <code title="">fefuncg</code> <td> <code title="">feFuncG</code>
+      <tr> <td> <code title="">fefuncr</code> <td> <code title="">feFuncR</code>
+      <tr> <td> <code title="">fegaussianblur</code> <td> <code title="">feGaussianBlur</code>
+      <tr> <td> <code title="">feimage</code> <td> <code title="">feImage</code>
+      <tr> <td> <code title="">femerge</code> <td> <code title="">feMerge</code>
+      <tr> <td> <code title="">femergenode</code> <td> <code title="">feMergeNode</code>
+      <tr> <td> <code title="">femorphology</code> <td> <code title="">feMorphology</code>
+      <tr> <td> <code title="">feoffset</code> <td> <code title="">feOffset</code>
+      <tr> <td> <code title="">fepointlight</code> <td> <code title="">fePointLight</code>
+      <tr> <td> <code title="">fespecularlighting</code> <td> <code title="">feSpecularLighting</code>
+      <tr> <td> <code title="">fespotlight</code> <td> <code title="">feSpotLight</code>
+      <tr> <td> <code title="">fetile</code> <td> <code title="">feTile</code>
+      <tr> <td> <code title="">feturbulence</code> <td> <code title="">feTurbulence</code>
+      <tr> <td> <code title="">foreignobject</code> <td> <code title="">foreignObject</code>
+      <tr> <td> <code title="">glyphref</code> <td> <code title="">glyphRef</code>
+      <tr> <td> <code title="">lineargradient</code> <td> <code title="">linearGradient</code>
+      <tr> <td> <code title="">radialgradient</code> <td> <code title="">radialGradient</code>
+      <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
+      <tr> <td> <code title="">textpath</code> <td> <code title="">textPath</code>
+    </table>
+
+    <p>If the <span>current node</span> is an element in the <span>SVG
+    namespace</span>, <span>adjust SVG attributes</span> for the
+    token. (This fixes the case of SVG attributes that are not all
+    lowercase.)</p>
+
+    <p><span>Adjust foreign attributes</span> for the token. (This
+    fixes the use of namespaced attributes, in particular XLink in
+    SVG.)</p>
+
+    <p><span>Insert a foreign element</span> for the token, in the
+    same namespace as the <span>current node</span>.</p>
+
+    <p>If the token has its <i>self-closing flag</i> set, pop the
+    <span>current node</span> off the <span>stack of open
+    elements</span> and <span title="acknowledge self-closing
+    flag">acknowledge the token's <i>self-closing flag</i></span>.</p>
+
+   </dd>
+
+   <dt id="scriptForeignEndTag">An end tag whose tag name is "script", if the <span>current node</span> is a <code title="">script</code> element in the <span>SVG namespace</span></dt>
+   <dd>
+
+    <p>Pop the <span>current node</span> off the <span>stack of open
+    elements</span>.</p>
+
+    <p>Let the <var title="">old insertion point</var> have the
+    same value as the current <span>insertion point</span>. Let
+    the <span>insertion point</span> be just before the <span>next
+    input character</span>.</p>
+
+    <p>Increment the parser's <span>script nesting level</span> by
+    one. Set the <span>parser pause flag</span> to true.</p>
+
+    <p><a
+    href="http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process
+    the <code title="">script</code> element</a> according to the SVG
+    rules, if the user agent supports SVG. <a
+    href="#refsSVG">[SVG]</a></p>
+
+    <p class="note">Even if this causes <span
+    title="dom-document-write">new characters to be inserted into the
+    tokenizer</span>, the parser will not be executed reentrantly,
+    since the <span>parser pause flag</span> is true.</p>
+
+    <p>Decrement the parser's <span>script nesting level</span> by
+    one. If the parser's <span>script nesting level</span> is zero,
+    then set the <span>parser pause flag</span> to false.</p>
+
+    <p>Let the <span>insertion point</span> have the value of the <var
+    title="">old insertion point</var>. (In other words, restore the
+    <span>insertion point</span> to its previous value. This value
+    might be the "undefined" value.)</p>
+
+   </dd>
+
+   <dt>Any other end tag</dt>
+
+   <dd>
+
+    <p>Run these steps:</p>
+
+    <ol>
+
+     <li><p>Initialize <var title="">node</var> to be the <span>current
+     node</span> (the bottommost node of the stack).</p></li>
+
+     <li><p>If <var title="">node</var> is not an element with the
+     same tag name as the token, then this is a <span>parse
+     error</span>.</p></li>
+
+     <li><p><i>Loop</i>: If <var title="">node</var>'s tag name,
+     <span>converted to ASCII lowercase</span>, is the same as as the
+     tag name of the token, pop elements from the <span>stack of open
+     elements</span> until <var title="">node</var> has been popped
+     from the stack, and then jump to the last step of this list of
+     steps.</p></li>
+
+     <li><p>Set <var title="">node</var> to the previous entry in the
+     <span>stack of open elements</span>.</p></li>
+
+     <li><p>If <var title="">node</var> is not an element in the
+     <span>HTML namespace</span>, return to the step labeled
+     <i>loop</i>.</p></li>
+
+     <li><p>Otherwise, process the token according to the rules given
+     in the section corresponding to the current <span>insertion
+     mode</span> in HTML content.</li>
+
+    </ol>
+
+   </dd>
+
+  </dl>
+
   </div>
 
 




More information about the Commit-Watchers mailing list