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