Permalink
Browse files

Support rb and rtc elements in the parser (ruby)

Ruby parsing got forked in two directions. This aligns the parser with the majority of implementations. Remaining implementations have agreed to make these changes as well, hopefully leading us back to fully interoperable HTML parsing.

This does not make either rb or rtc elements conforming. It also does not change any rendering rules. That is separately discussed in #121.
  • Loading branch information...
annevk committed Sep 10, 2015
1 parent c6d4dda commit 8d1c8affec71058de29f8051cb2fa7f7bbad1fe6
Showing with 48 additions and 49 deletions.
  1. +48 −49 source
View
97 source
@@ -103826,9 +103826,10 @@ document.body.appendChild(text);
<p>When the steps below require the UA to <dfn>generate implied end tags</dfn>, then, while the
<span>current node</span> is a <code>dd</code> element, a <code>dt</code> element, an
- <code>li</code> element, an <code>option</code> element, an <code>optgroup</code> element, a
- <code>p</code> element, an <code>rp</code> element, or an <code>rt</code> element, the UA must pop
- the <span>current node</span> off the <span>stack of open elements</span>.</p>
+ <code>li</code> element, an <code>optgroup</code> element, an <code>option</code> element, a
+ <code>p</code> element, an <code>rb</code> element, an <code>rp</code> element, an <code>rt</code>
+ element, or an <code>rtc</code> element, the UA must pop the <span>current node</span> off the
+ <span>stack of open elements</span>.</p>
<p>If a step requires the UA to generate implied end tags but lists an element to exclude from the
process, then the UA must perform the above steps as if that element was not in the above
@@ -103837,11 +103838,12 @@ document.body.appendChild(text);
<p>When the steps below require the UA to <dfn>generate all implied end tags thoroughly</dfn>,
then, while the <span>current node</span> is a <code>caption</code> element, a
<code>colgroup</code> element, a <code>dd</code> element, a <code>dt</code> element, an
- <code>li</code> element, an <code>option</code> element, an <code>optgroup</code> element, a
- <code>p</code> element, an <code>rp</code> element, an <code>rt</code> element, a
- <code>tbody</code> element, a <code>td</code> element, a <code>tfoot</code> element, a
- <code>th</code> element, a <code>thead</code> element, or a <code>tr</code> element, the UA must
- pop the <span>current node</span> off the <span>stack of open elements</span>.</p>
+ <code>li</code> element, an <code>optgroup</code> element, an <code>option</code> element, a
+ <code>p</code> element, an <code>rb</code> element, an <code>rp</code> element, an <code>rt</code>
+ element, an <code>rtc</code> element, a <code>tbody</code> element, a <code>td</code> element, a
+ <code>tfoot</code> element, a <code>th</code> element, a <code>thead</code> element, or a
+ <code>tr</code> element, the UA must pop the <span>current node</span> off the
+ <span>stack of open elements</span>.</p>
@@ -104749,11 +104751,11 @@ document.body.appendChild(text);
<li><p>If there is a node in the <span>stack of open elements</span> that is not either a
<code>dd</code> element, a <code>dt</code> element, an <code>li</code> element, an
<code>optgroup</code> element, an <code>option</code> element, a <code>p</code> element, an
- <code>rp</code> element, an <code>rt</code> element, a <code>tbody</code> element, a
- <code>td</code> element, a <code>tfoot</code> element, a <code>th</code> element, a
- <code>thead</code> element, a <code>tr</code> element, the <code>body</code> element, or the
- <code>html</code> element, then this is a <span>parse error</span>.</p></li> <!-- (some of
- those are fragment cases) -->
+ <code>rb</code> element, an <code>rp</code> element, an <code>rt</code> element, an
+ <code>rtc</code> element, a <code>tbody</code> element, a <code>td</code> element, a
+ <code>tfoot</code> element, a <code>th</code> element, a <code>thead</code> element, a
+ <code>tr</code> element, the <code>body</code> element, or the <code>html</code> element, then
+ this is a <span>parse error</span>.</p></li> <!-- (some of those are fragment cases) -->
<li><p><span>Stop parsing</span>.</p></li>
@@ -104773,12 +104775,13 @@ document.body.appendChild(text);
<p>Otherwise, if there is a node in the <span>stack of open elements</span> that is not either a
<code>dd</code> element, a <code>dt</code> element, an <code>li</code> element, an
<code>optgroup</code> element, an <code>option</code> element, a <code>p</code> element, an
- <code>rp</code> element, an <code>rt</code> element, a <code>tbody</code> element, a
- <code>td</code> element, a <code>tfoot</code> element, a <code>th</code> element, a
- <code>thead</code> element, a <code>tr</code> element, the <code>body</code> element, or the
- <code>html</code> element, then this is a <span>parse error</span>.</p> <!-- (some of those are
- fragment cases, e.g. for <tbody> you'd have hit the first paragraph since the <body> wouldn't be
- in scope, unless it was a fragment case) -->
+ <code>rb</code> element, an <code>rp</code> element, an <code>rt</code> element, an
+ <code>rtc</code> element, a <code>tbody</code> element, a <code>td</code> element, a
+ <code>tfoot</code> element, a <code>th</code> element, a <code>thead</code> element, a
+ <code>tr</code> element, the <code>body</code> element, or the <code>html</code> element, then
+ this is a <span>parse error</span>.</p> <!-- (some of those are fragment cases, e.g., for
+ <tbody> you'd have hit the first paragraph since the <body> wouldn't be in scope, unless it was
+ a fragment case) -->
<!-- If we ever change the frameset-ok flag to an insertion mode, then we'd have to somehow keep
track of its state when we switch to after-body. -->
@@ -104801,12 +104804,13 @@ document.body.appendChild(text);
<p>Otherwise, if there is a node in the <span>stack of open elements</span> that is not either a
<code>dd</code> element, a <code>dt</code> element, an <code>li</code> element, an
<code>optgroup</code> element, an <code>option</code> element, a <code>p</code> element, an
- <code>rp</code> element, an <code>rt</code> element, a <code>tbody</code> element, a
- <code>td</code> element, a <code>tfoot</code> element, a <code>th</code> element, a
- <code>thead</code> element, a <code>tr</code> element, the <code>body</code> element, or the
- <code>html</code> element, then this is a <span>parse error</span>.</p> <!-- (some of those are
- fragment cases, e.g. for <tbody> you'd have hit the first paragraph since the <body> wouldn't be
- in scope, unless it was a fragment case) -->
+ <code>rb</code> element, an <code>rp</code> element, an <code>rt</code> element, an
+ <code>rtc</code> element, a <code>tbody</code> element, a <code>td</code> element, a
+ <code>tfoot</code> element, a <code>th</code> element, a <code>thead</code> element, a
+ <code>tr</code> element, the <code>body</code> element, or the <code>html</code> element, then
+ this is a <span>parse error</span>.</p> <!-- (some of those are fragment cases, e.g., for
+ <tbody> you'd have hit the first paragraph since the <body> wouldn't be in scope, unless it was
+ a fragment case) -->
<!-- If we ever change the frameset-ok flag to an insertion mode, then we'd have to somehow keep
track of its state when we switch to after-body. -->
@@ -105652,32 +105656,25 @@ document.body.appendChild(text);
</dd>
- <dt>A start tag whose tag name is one of: "rp", "rt"</dt>
+ <dt>A start tag whose tag name is one of: "rb", "rtc"</dt>
<dd>
- <!-- the parsing rules for ruby really don't match IE much at all, but in practice the markup
- used is very simple and so strict compatibility with IE isn't required. For example, as
- defined here we get very, very different behaviour than IE for pathological cases like:
-
- <ruby><ol><li><p>a<rt>b
- <ruby>a<rt>b<p>c
-
- But in practice most ruby markup falls into these cases:
+ <p>If the <span>stack of open elements</span> <span data-x="has an element in scope">has a
+ <code>ruby</code> element in scope</span>, then <span>generate implied end tags</span>. If the
+ <span>current node</span> is not now a <code>ruby</code> element, this is a
+ <span>parse error</span>.</p>
- <ruby>a<rt>b</ruby>
- <ruby>a<rp>b<rt>c<rp>d</ruby>
- <ruby>a<rt>b</rt></ruby>
- <ruby>a<rp>b</rp><rt>c</rt><rp>d</rp></ruby>
+ <p><span>Insert an HTML element</span> for the token.</p>
- (Note: the comment above was written when this section did something slightly more radical
- for handling <rp> and <rt> elements, so it might be out of date now.)
+ </dd>
- -->
+ <dt>A start tag whose tag name is one of: "rp", "rt"</dt>
+ <dd>
<p>If the <span>stack of open elements</span> <span data-x="has an element in scope">has a
- <code>ruby</code> element in scope</span>, then <span>generate implied end tags</span>. If the
- <span>current node</span> is not then a <code>ruby</code> element, this is a <span>parse
- error</span>.</p>
+ <code>ruby</code> element in scope</span>, then <span>generate implied end tags</span>, except
+ for <code>rtc</code> elements. If the <span>current node</span> is not now a <code>rtc</code>
+ element or a <code>ruby</code> element, this is a <span>parse error</span>.</p>
<p><span>Insert an HTML element</span> for the token.</p>
@@ -111991,7 +111988,9 @@ if (s = prompt('What is your name?')) {
<dd><p>Use the "<code>text/plain</code>" <span>MIME type</span> instead.</p></dd>
<dt><dfn><code>rb</code></dfn></dt>
- <dd><p>Providing the ruby base directly inside the <code>ruby</code> element is sufficient; the <code>rb</code> element is unnecessary. Omit it altogether.</p></dd>
+ <dt><dfn><code>rtc</code></dfn></dt>
+ <dd><p>Providing the ruby base directly inside the <code>ruby</code> element or using nested
+ <code>ruby</code> elements is sufficient.</p></dd>
<dt><dfn><code>strike</code></dfn></dt>
<dd><p>Use <code>del</code> instead if the element is marking an edit, otherwise use <code>s</code> instead.</p></dd>
@@ -113396,10 +113395,10 @@ if (s = prompt('What is your name?')) {
<hr>
<p>The <code>blink</code>, <code>bgsound</code>, <code>isindex</code>, <code>multicol</code>,
- <code>nextid</code>, <code>rb</code>, and <code>spacer</code> elements must use the
- <code>HTMLUnknownElement</code> interface.</p> <!-- has to be explicitly listed because
- technically we define the elements in the spec, albeit as obsolete, and then we say that only
- elements not defined in this spec use HTMLUnknownElement. -->
+ <code>nextid</code>, and <code>spacer</code> elements must use the <code>HTMLUnknownElement</code>
+ interface.</p> <!-- has to be explicitly listed because technically we define the elements in the
+ spec, albeit as obsolete, and then we say that only elements not defined in this spec use
+ HTMLUnknownElement. -->
<hr>

0 comments on commit 8d1c8af

Please sign in to comment.