Skip to content

Commit caa815e

Browse files
pchampingkellogg
authored andcommitted
A proposal to make algotithms easier to read using foldable sections.
1 parent 717ea94 commit caa815e

File tree

1 file changed

+35
-16
lines changed

1 file changed

+35
-16
lines changed

index.html

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,24 @@
264264
text-decoration: none;
265265
color: #666;
266266
}
267+
268+
.algorithm summary::before {
269+
content: "// ";
270+
}
271+
272+
.algorithm summary {
273+
padding-left: 2em;
274+
font-style: italic;
275+
}
276+
277+
/* required if we chose to put OLs *outside* the details,
278+
to force them visible when printing */
279+
@media screen {
280+
.algorithm details:not([open]) + ol {
281+
display: none;
282+
}
283+
}
284+
267285
</style>
268286
</head>
269287

@@ -1073,6 +1091,7 @@ <h3>Algorithm</h3>
10731091
For each item <var>context</var> in <var>local context</var>:
10741092
<ol>
10751093
<li>If <var>context</var> is <code>null</code>:
1094+
<details><summary>clear context (unless protected)</summary></details>
10761095
<ol>
10771096
<li class="changed">If <var>override protected</var> is <code>false</code> and <var>active context</var>
10781097
contains any <a>protected</a> <a>term definitions</a>,
@@ -1086,10 +1105,10 @@ <h3>Algorithm</h3>
10861105
<span class="note">In [[[JSON-LD]]], the <a>base IRI</a> was given
10871106
a default value here; this is now described conditionally
10881107
in <a href="#the-application-programming-interface" class="sectionRef"></a>.</span></li>
1089-
</ol>
1108+
</ol>
10901109
</li>
1091-
<li>If <var>context</var> is a <a>string</a>,
1092-
<ol>
1110+
<li>If <var>context</var> is a <a>string</a>:
1111+
<details><summary>dereference and process</summary><ol>
10931112
<li>Set <var>context</var> to the result of resolving <var>value</var> against
10941113
the base IRI which is established as specified in
10951114
<a data-cite="RFC3986#section-5.1">section 5.1 Establishing a Base URI</a>
@@ -1129,14 +1148,14 @@ <h3>Algorithm</h3>
11291148
passing <var>result</var> for <var>active context</var>,
11301149
<var>context</var> for <var>local context</var>, and <span class="changed">a copy of</span> <var>remote contexts</var>.</li>
11311150
<li>Continue with the next <var>context</var>.</li>
1132-
</ol>
1151+
</ol></details>
11331152
</li>
11341153
<li>If <var>context</var> is not a <a class="changed">map</a>, an
11351154
<a data-link-for="JsonLdErrorCode">invalid local context</a>
11361155
error has been detected and processing is aborted.</li>
11371156
<li>Otherwise, <var>context</var> is a <a data-cite="JSON-LD11#dfn-context-definition">context definition</a>.</li>
11381157
<li class="changed">If <var>context</var> has an <code>@version</code> <a>entry</a>:
1139-
<ol>
1158+
<details><summary>set processing mode</summary><ol>
11401159
<li>If the associated value is not <code>1.1</code>,
11411160
an <a data-link-for="JsonLdErrorCode">invalid @version value</a>
11421161
has been detected, and processing is aborted.</li>
@@ -1146,10 +1165,10 @@ <h3>Algorithm</h3>
11461165
error has been detected and processing is aborted.</li>
11471166
<li>Set <a>processing mode</a>,
11481167
to <code>json-ld-1.1</code>, if not already set.</li>
1149-
</ol>
1168+
</ol></details>
11501169
</li>
11511170
<li class="changed">If <var>context</var> has an <code>@import</code> <a>entry</a>:
1152-
<ol>
1171+
<details><summary>merge imported context</summary><ol>
11531172
<li>If <a>processing mode</a> is <code>json-ld-1.0</code>,
11541173
an <a data-link-for="JsonLdErrorCode">invalid context entry</a>
11551174
error has been detected and processing is aborted.</li>
@@ -1191,11 +1210,11 @@ <h3>Algorithm</h3>
11911210
<li>Set <var>context</var> to the result of merging <var>context</var>
11921211
into <var>import context</var>, replacing common entries
11931212
with those from <var>context</var>.</li>
1194-
</ol>
1213+
</ol></details>
11951214
</li>
11961215
<li>If <var>context</var> has an <code>@base</code> <a>entry</a> and <var>remote contexts</var> is empty, i.e., the currently
11971216
being processed context is not a remote context:
1198-
<ol>
1217+
<details><summary>reset <a>base IRI</a></summary><ol>
11991218
<li>Initialize <var>value</var> to the value associated with the
12001219
<code>@base</code> <a>entry</a>.</li>
12011220
<li>If <var>value</var> is <code>null</code>, remove the
@@ -1210,10 +1229,10 @@ <h3>Algorithm</h3>
12101229
<li>Otherwise, an
12111230
<a data-link-for="JsonLdErrorCode">invalid base IRI</a>
12121231
error has been detected and processing is aborted.</li>
1213-
</ol>
1232+
</ol></details>
12141233
</li>
12151234
<li>If <var>context</var> has an <code>@vocab</code> <a>entry</a>:
1216-
<ol>
1235+
<details><summary>reset <a>vocabulary mapping</a></summary><ol>
12171236
<li>Initialize <var>value</var> to the value associated with the
12181237
<code>@vocab</code> <a>entry</a>.</li>
12191238
<li>If <var>value</var> is <a>null</a>, remove
@@ -1234,10 +1253,10 @@ <h3>Algorithm</h3>
12341253
error has been detected and processing is aborted.
12351254
<div class="note">The use of <a>blank node identifiers</a> to value for <code>@vocab</code> is obsolete,
12361255
and may be removed in a future version of JSON-LD.</div></li>
1237-
</ol>
1256+
</ol></details>
12381257
</li>
12391258
<li>If <var>context</var> has an <code>@language</code> <a>entry</a>:
1240-
<ol>
1259+
<details><summary>reset <a>default language</a></summary><ol>
12411260
<li>Initialize <var>value</var> to the value associated with the
12421261
<code>@language</code> <a>entry</a>.</li>
12431262
<li>If <var>value</var> is <code>null</code>, remove
@@ -1247,10 +1266,10 @@ <h3>Algorithm</h3>
12471266
lowercased <var>value</var>. If it is not a <a>string</a>, an
12481267
<a data-link-for="JsonLdErrorCode">invalid default language</a>
12491268
error has been detected and processing is aborted.</li>
1250-
</ol>
1269+
</ol></details>
12511270
</li>
12521271
<li class="changed">If <var>context</var> has an <code>@propagate</code> <a>entry</a>:
1253-
<ol>
1272+
<details><summary>check its validity</summary><ol>
12541273
<li>If <a>processing mode</a> is <code>json-ld-1.0</code>,
12551274
an <a data-link-for="JsonLdErrorCode">invalid context entry</a>
12561275
error has been detected and processing is aborted.</li>
@@ -1259,7 +1278,7 @@ <h3>Algorithm</h3>
12591278
error has been detected and processing is aborted.</li>
12601279
<li>Otherwise, <a>previous context</a> was determined before,
12611280
and no further processing is necessary.</li>
1262-
</ol>
1281+
</ol></details>
12631282
</li>
12641283
<li>Create a <a class="changed">map</a> <var>defined</var> to keep
12651284
track of whether or not a <a>term</a> has already been defined

0 commit comments

Comments
 (0)