Skip to content
Permalink
Browse files

[cgiowt] (3) Parser change: Handle fragment case for non-HTML nodes. …

…This _should_ have no effect on any other case, so please do let me know if this breaks any tests!

Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=17924
Affected topics: HTML Syntax and Parsing

git-svn-id: http://svn.whatwg.org/webapps@7768 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Mar 25, 2013
1 parent 3892d6b commit f6ef2f350414c1337e4924c30de5005042a4f4c6
Showing with 104 additions and 44 deletions.
  1. +35 −15 complete.html
  2. +35 −15 index
  3. +34 −14 source

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 22 March 2013</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 25 March 2013</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>

</ol><h5 id=the-stack-of-open-elements><span class=secno>12.2.3.2 </span>The stack of open elements</h5>

<!--CLEANUP-->
<p>Initially, the <dfn id=stack-of-open-elements>stack of open elements</dfn> is empty. The
stack grows downwards; the topmost node on the stack is the first
one added to the stack, and the bottommost node of the stack is the
most recently added node in the stack (notwithstanding when the
stack is manipulated in a random access fashion as part of <a href=#adoptionAgency>the handling for misnested tags</a>).</p>

<p>The "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before
<p class=note>The "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before
html</a>" <a href=#insertion-mode>insertion mode</a> creates the
<code><a href=#the-html-element>html</a></code> root element node, which is then added to the
stack.</p>

<p>In the <a href=#fragment-case>fragment case</a>, the <a href=#stack-of-open-elements>stack of open
<p class=note>In the <a href=#fragment-case>fragment case</a>, the <a href=#stack-of-open-elements>stack of open
elements</a> is initialized to contain an <code><a href=#the-html-element>html</a></code>
element that is created as part of <a href=#html-fragment-parsing-algorithm title="html fragment
parsing algorithm">that algorithm</a>. (The <a href=#fragment-case>fragment
<a href=#stop-parsing title="stop parsing">finishes</a>.</p>

<p>The <dfn id=current-node>current node</dfn> is the bottommost node in this
stack.</p>
<a href=#stack-of-open-elements>stack of open elements</a>.</p>

<p>Elements in the stack fall into the following categories:</p>
<p>The <dfn id=adjusted-current-node>adjusted current node</dfn> is the <i title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></i>
element if the <a href=#stack-of-open-elements>stack of open elements</a> has only one element in it and the parser was
created by the <a href=#html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a>; otherwise, the <a href=#adjusted-current-node>adjusted current
node</a> is the <a href=#current-node>current node</a>.</p>

<p>Elements in the <a href=#stack-of-open-elements>stack of open elements</a> fall into the following categories:</p>

<dl><dt><dfn id=special>Special</dfn></dt>
<dd><p>The following elements have varying levels of special parsing rules: HTML's
the stack when you hit a limit, or something. -->

<h4 id=tree-construction><span class=secno>12.2.5 </span><dfn>Tree construction</dfn></h4>
<!--CLEANUP-->

<p>The input to the tree construction stage is a sequence of tokens
from the <a href=#tokenization>tokenization</a> stage. The tree construction
<hr><p>As each token is emitted from the tokenizer, the user agent must
follow the appropriate steps from the following list:</p>

<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 a <a href=#mathml-text-integration-point>MathML text integration point</a> and the token is a character token</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>
<dl class=switch><dt>If there is no <a href=#adjusted-current-node>adjusted current node</a></dt>
<dt>If the <a href=#adjusted-current-node>adjusted current node</a> is an element in the <a href=#html-namespace-0>HTML namespace</a></dt>
<dt>If the <a href=#adjusted-current-node>adjusted 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=#adjusted-current-node>adjusted current node</a> is a <a href=#mathml-text-integration-point>MathML text integration point</a> and the token is a character token</dt>
<dt>If the <a href=#adjusted-current-node>adjusted 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=#adjusted-current-node>adjusted 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=#adjusted-current-node>adjusted 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
if a token had been seen</dfn>, it means that the user agent is to
follow the appropriate steps from the above list.</p>

<p>The <a href=#current-node>current node</a> is a <dfn id=mathml-text-integration-point>MathML text
<p>A node 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
</ul><p>A node 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>
</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>
<!--CLEANUP-->

<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>


<p><a href=#parse-error>Parse error</a>.</p>

<p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-scope title="has an element in
scope">have an element in scope</a> that 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>, or if the
<a href=#stack-of-open-elements>stack of open elements</a> has only one element, then 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>. (<a href=#fragment-case>fragment case</a>)</p>

<p>Otherwise:</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
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,
<li><p><i>Loop</i>: If <var title="">node</var> is the topmost element in the <a href=#stack-of-open-elements>stack of
open elements</a>, abort these steps. (<a href=#fragment-case>fragment case</a>)</li>

<li><p>If <var title="">node</var>'s tag name,
<a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>, is the same 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

0 comments on commit f6ef2f3

Please sign in to comment.