Skip to content

Commit d9f9293

Browse files
committed
various fixes for the issues raised in #179;
add rel tokenization
1 parent a6b77a8 commit d9f9293

File tree

1 file changed

+48
-37
lines changed

1 file changed

+48
-37
lines changed

index.html

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4769,6 +4769,11 @@

User Agent Processing

47694769
<p>If a table of contents element is not found, the publication does not have a table of contents that
47704770
can be used for machine rendering purposes.p>
47714771

4772+
<p class="note">This algorithm is not defined in purely event driven terms, as inspecting all descendant
4773+
nodes is not necessary to obtain the needed information from the DOM. In some cases, an element is
4774+
exited immediately after it is processed. An event approach could be applied, but would require
4775+
modifying the algorithm to process/ignore the omitted nodes.p>
4776+
47724777
<ol>
47734778
<li id="toc-initialize-toc">
47744779
<p>Let <var>tocvar> be the <a href="https://infra.spec.whatwg.org/#ordered-map">mapa>
@@ -4885,8 +4890,7 @@

User Agent Processing

48854890
<a href="https://infra.spec.whatwg.org/#list">lista>, exit the
48864891
element and continue processing with the next element.li>
48874892
<li>Otherwise, <a href="https://infra.spec.whatwg.org/#stack-push">pusha>
4888-
the <a href="https://infra.spec.whatwg.org/#ordered-map">mapa> in
4889-
<var>current_toc_branchvar> onto <var>branchesvar> and set
4893+
<var>current_toc_branchvar> onto <var>branchesvar> and then set
48904894
<var>current_toc_branchvar> to <a
48914895
href="https://infra.spec.whatwg.org/#nulls">nulla>.li>
48924896
ol>
@@ -4923,14 +4927,26 @@

User Agent Processing

49234927
<p>
49244928
<strong>When exiting a <a>list elementa>:strong>
49254929
p>
4926-
<p>If <var>branchesvar> is not empty, <a
4927-
href="https://infra.spec.whatwg.org/#stack-pop">popa> the top <a
4928-
href="https://infra.spec.whatwg.org/#ordered-map">mapa> from
4929-
<var>branchesvar> and set <var>current_toc_branchvar> to it.p>
4930+
<ol>
4931+
<li>
4932+
<p>If <var>branchesvar> is not empty, <a
4933+
href="https://infra.spec.whatwg.org/#stack-pop">popa> the top <a
4934+
href="https://infra.spec.whatwg.org/#ordered-map">mapa> from
4935+
<var>branchesvar> and set <var>current_toc_branchvar> to it.p>
4936+
li>
4937+
<li>
4938+
<p>Otherwise, if <var>toc.entriesvar> contains an empty <a
4939+
href="https://infra.spec.whatwg.org/#list">lista>, set it to <a
4940+
href="https://infra.spec.whatwg.org/#nulls">nulla>.p>
4941+
li>
4942+
ol>
49304943
<details>
49314944
<summary>Explanationsummary>
4932-
<p>This resets <var>current_toc_branchvar> back to the parent object after all of
4933-
its child branches have been processed.p>
4945+
<p>This step resets <var>current_toc_branchvar> back to the parent object after
4946+
all of its child branches have been processed.p>
4947+
<p>If there are no branches in the stack, the <var>toc.entriesvar> is set to null
4948+
if it doesn't contain any items (to avoid processing any further lists at the
4949+
root level).p>
49344950
details>
49354951
li>
49364952

@@ -4958,7 +4974,7 @@

User Agent Processing

49584974
details>
49594975
li>
49604976

4961-
<li id="toc-dom-exist-list">
4977+
<li id="toc-dom-exit-li">
49624978
<p>
49634979
<strong>When exiting a <a
49644980
href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-li-element"
@@ -4972,31 +4988,25 @@

User Agent Processing

49724988
href="https://infra.spec.whatwg.org/#nulls">nulla>.p>
49734989
li>
49744990
<li>
4975-
<p>If <var>branchesvar> is not empty:p>
4991+
<p>If <var>current_toc_branch["name"]var> is an empty string:p>
49764992
<ol>
4977-
<li>if the <var>current_toc_branch["entries"]var> contains a non-empty <a
4978-
href="https://infra.spec.whatwg.org/#list">lista>, and
4979-
<var>current_toc_branch["name"]var> is an empty string, set
4993+
<li>if <var>current_toc_branch["entries"]var> is not <a
4994+
href="https://infra.spec.whatwg.org/#nulls">nulla>, set
49804995
<var>current_toc_branch["name"]var> to a placeholder value or <a
49814996
href="https://infra.spec.whatwg.org/#nulls">nulla>;li>
4982-
<li>if the <var>current_toc_branch["entries"]var> contains an empty <a
4983-
href="https://infra.spec.whatwg.org/#list">lista>, and
4984-
<code>current_toc_branch["name"]code> is an empty <a
4985-
href="https://infra.spec.whatwg.org/#string">stringa>, set
4986-
<var>current_toc_branchvar> to <a
4997+
<li>otherwise, set <var>current_toc_branchvar> to <a
49874998
href="https://infra.spec.whatwg.org/#nulls">nulla> and exit this
49884999
processing step.li>
49895000
ol>
4990-
<p><a href="https://infra.spec.whatwg.org/#list-append">Appenda> the <a
4991-
href="https://infra.spec.whatwg.org/#ordered-map">mapa> in
4992-
<var>current_toc_branchvar> to the <var>entriesvar> property of the
4993-
<a href="https://infra.spec.whatwg.org/#ordered-map">mapa> at the top
4994-
of <var>branchesvar>.p>
49955001
li>
49965002
<li>
4997-
<p>Otherwise, <a href="https://infra.spec.whatwg.org/#list-append">appenda>
4998-
the <a href="https://infra.spec.whatwg.org/#ordered-map">mapa> in
4999-
<var>current_toc_branchvar> to <var>toc["entries"]var>.p>
5003+
<p>If <var>branchesvar> is not empty, <a
5004+
href="https://infra.spec.whatwg.org/#list-append">appenda>
5005+
<var>current_toc_branchvar> to the <var>entriesvar> property of the <a
5006+
href="https://infra.spec.whatwg.org/#ordered-map">mapa> at the top of
5007+
<var>branchesvar>. Otherwise, <a
5008+
href="https://infra.spec.whatwg.org/#list-append">appenda>
5009+
<var>current_toc_branchvar> to <var>toc["entries"]var>.p>
50005010
li>
50015011

50025012
<li>
@@ -5020,15 +5030,16 @@

User Agent Processing

50205030
<p>As a final step, <var>current_toc_branchvar> is reset back to
50215031
<code>nullcode>.p>
50225032
<aside class="example" title="Visualization of a branch merge.">
5023-
<p>If the following two maps are in <var>current_toc_branchvar>p>
5033+
<p>If the following map is in <var>branchesvar>:p>
50245034
<pre>«[
50255035
"name" → "Section 1",
50265036
"url" → "http://example.com/contents.html#s1",
50275037
"type" → "text/html",
50285038
"rel" → null,
50295039
"entries" → « »
5030-
]»,
5031-
«[
5040+
pre>
5041+
<p>And the following map is in <var>current_toc_branch:var>p>
5042+
<pre>«[
50325043
"name" → "Section 1.1",
50335044
"url" → "http://example.com/contents.html#s1.1",
50345045
"type" → "text/html",
@@ -5090,8 +5101,8 @@

User Agent Processing

50905101
href="https://infra.spec.whatwg.org/#nulls">nulla>.p>
50915102
li>
50925103
<li>If the element has an <code>hrefcode> attribute and the URL in the
5093-
attribute resolves to a resource in the <a>default reading ordera> or
5094-
<a>resource lista>, set <var>current_toc_branch["url"]var> to
5104+
attribute resolves to a resource in <a href="#reslist-end"
5105+
>uniqueResourcesa>, set <var>current_toc_branch["url"]var> to
50955106
the value. Otherwise, set <var>current_toc_branch["url"]var> to <a
50965107
href="https://infra.spec.whatwg.org/#nulls">nulla>.li>
50975108
<li>If the element has a <code>typecode> attribute, and the value of the
@@ -5101,8 +5112,10 @@

User Agent Processing

51015112
href="https://infra.spec.whatwg.org/#nulls">nulla>.li>
51025113
<li>If the element has a <code>relcode> attribute, and the value of the
51035114
attribute is not an empty string after trimming leading and trailing
5104-
white space, set <var>current_toc_branch["rel"]var> to the trimmed
5105-
value. Otherwise, set <var>current_toc_branch["rel"]var> to <a
5115+
white space, split the trimmed value on whitespace and set
5116+
<var>current_toc_branch["rel"]var> to the resulting <a
5117+
href="https://infra.spec.whatwg.org/#list">lista> of tokens.
5118+
Otherwise, set <var>current_toc_branch["rel"]var> to <a
51065119
href="https://infra.spec.whatwg.org/#nulls">nulla>.li>
51075120
ol>
51085121
<p>Exit the element and continue processing with the next element.p>
@@ -5172,10 +5185,8 @@

User Agent Processing

51725185

51735186
<li id="toc-finish">
51745187
<p>After completing the DOM walk, if <var>toc["entries"]var> contains a non-empty <a
5175-
href="https://infra.spec.whatwg.org/#list">lista>, <var>tocvar> represents the
5176-
machine-processed table of contents.p>
5177-
<p>Otherwise, the digital publication does not have a table of contents that can be used for
5178-
machine rendering purposes.p>
5188+
href="https://infra.spec.whatwg.org/#list">lista>, return <var>tocvar>. Otherwise,
5189+
return <code>nullcode>.p>
51795190
<details>
51805191
<summary>Explanationsummary>
51815192
<p>If the <code>entriescode> array in the root <em>tocem> object does not contain any

0 commit comments

Comments
 (0)