Skip to content

Commit e4bcc78

Browse files
committed
A proposal to make algotithms easier to read using foldable sections.
1 parent fc7d580 commit e4bcc78

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

@@ -1125,6 +1143,7 @@ <h3>Algorithm</h3>
11251143
For each item <var>context</var> in <var>local context</var>:
11261144
<ol>
11271145
<li>If <var>context</var> is <code>null</code>:
1146+
<details><summary>clear context (unless protected)</summary></details>
11281147
<ol>
11291148
<li class="changed">If <var>override protected</var> is <code>false</code> and <var>active context</var>
11301149
contains any <a>protected</a> <a>term definitions</a>,
@@ -1138,10 +1157,10 @@ <h3>Algorithm</h3>
11381157
<span class="note">In [[[JSON-LD]]], the <a>base IRI</a> was given
11391158
a default value here; this is now described conditionally
11401159
in <a href="#the-application-programming-interface" class="sectionRef"></a>.</span></li>
1141-
</ol>
1160+
</ol>
11421161
</li>
1143-
<li>If <var>context</var> is a <a>string</a>,
1144-
<ol>
1162+
<li>If <var>context</var> is a <a>string</a>:
1163+
<details><summary>dereference and process</summary><ol>
11451164
<li>Set <var>context</var> to the result of resolving <var>value</var> against
11461165
the base IRI which is established as specified in
11471166
<a data-cite="RFC3986#section-5.1">section 5.1 Establishing a Base URI</a>
@@ -1180,14 +1199,14 @@ <h3>Algorithm</h3>
11801199
passing <var>result</var> for <var>active context</var>,
11811200
<var>context</var> for <var>local context</var>, and <span class="changed">a copy of</span> <var>remote contexts</var>.</li>
11821201
<li>Continue with the next <var>context</var>.</li>
1183-
</ol>
1202+
</ol></details>
11841203
</li>
11851204
<li>If <var>context</var> is not a <a class="changed">map</a>, an
11861205
<a data-link-for="JsonLdErrorCode">invalid local context</a>
11871206
error has been detected and processing is aborted.</li>
11881207
<li>Otherwise, <var>context</var> is a <a data-cite="JSON-LD11#dfn-context-definition">context definition</a>.</li>
11891208
<li class="changed">If <var>context</var> has an <code>@version</code> <a>entry</a>:
1190-
<ol>
1209+
<details><summary>set processing mode</summary><ol>
11911210
<li>If the associated value is not <code>1.1</code>,
11921211
an <a data-link-for="JsonLdErrorCode">invalid @version value</a>
11931212
has been detected, and processing is aborted.</li>
@@ -1197,10 +1216,10 @@ <h3>Algorithm</h3>
11971216
error has been detected and processing is aborted.</li>
11981217
<li>Set <a>processing mode</a>,
11991218
to <code>json-ld-1.1</code>, if not already set.</li>
1200-
</ol>
1219+
</ol></details>
12011220
</li>
12021221
<li class="changed">If <var>context</var> has an <code>@import</code> <a>entry</a>:
1203-
<ol>
1222+
<details><summary>merge imported context</summary><ol>
12041223
<li>If <a>processing mode</a> is <code>json-ld-1.0</code>,
12051224
an <a data-link-for="JsonLdErrorCode">invalid context entry</a>
12061225
error has been detected and processing is aborted.</li>
@@ -1241,11 +1260,11 @@ <h3>Algorithm</h3>
12411260
<li>Set <var>context</var> to the result of merging <var>context</var>
12421261
into <var>import context</var>, replacing common entries
12431262
with those from <var>context</var>.</li>
1244-
</ol>
1263+
</ol></details>
12451264
</li>
12461265
<li>If <var>context</var> has an <code>@base</code> <a>entry</a> and <var>remote contexts</var> is empty, i.e., the currently
12471266
being processed context is not a remote context:
1248-
<ol>
1267+
<details><summary>reset <a>base IRI</a></summary><ol>
12491268
<li>Initialize <var>value</var> to the value associated with the
12501269
<code>@base</code> <a>entry</a>.</li>
12511270
<li>If <var>value</var> is <code>null</code>, remove the
@@ -1260,10 +1279,10 @@ <h3>Algorithm</h3>
12601279
<li>Otherwise, an
12611280
<a data-link-for="JsonLdErrorCode">invalid base IRI</a>
12621281
error has been detected and processing is aborted.</li>
1263-
</ol>
1282+
</ol></details>
12641283
</li>
12651284
<li>If <var>context</var> has an <code>@vocab</code> <a>entry</a>:
1266-
<ol>
1285+
<details><summary>reset <a>vocabulary mapping</a></summary><ol>
12671286
<li>Initialize <var>value</var> to the value associated with the
12681287
<code>@vocab</code> <a>entry</a>.</li>
12691288
<li>If <var>value</var> is <a>null</a>, remove
@@ -1284,10 +1303,10 @@ <h3>Algorithm</h3>
12841303
error has been detected and processing is aborted.
12851304
<div class="issue atrisk">The use of <a>blank node identifiers</a> to value for <code>@vocab</code> is obsolete,
12861305
and may be removed in a future version of JSON-LD.</div></li>
1287-
</ol>
1306+
</ol></details>
12881307
</li>
12891308
<li>If <var>context</var> has an <code>@language</code> <a>entry</a>:
1290-
<ol>
1309+
<details><summary>reset <a>default language</a></summary><ol>
12911310
<li>Initialize <var>value</var> to the value associated with the
12921311
<code>@language</code> <a>entry</a>.</li>
12931312
<li>If <var>value</var> is <code>null</code>, remove
@@ -1297,10 +1316,10 @@ <h3>Algorithm</h3>
12971316
lowercased <var>value</var>. If it is not a <a>string</a>, an
12981317
<a data-link-for="JsonLdErrorCode">invalid default language</a>
12991318
error has been detected and processing is aborted.</li>
1300-
</ol>
1319+
</ol></details>
13011320
</li>
13021321
<li class="changed">If <var>context</var> has an <code>@propagate</code> <a>entry</a>:
1303-
<ol>
1322+
<details><summary>check its validity</summary><ol>
13041323
<li>If <a>processing mode</a> is <code>json-ld-1.0</code>,
13051324
an <a data-link-for="JsonLdErrorCode">invalid context entry</a>
13061325
error has been detected and processing is aborted.</li>
@@ -1309,7 +1328,7 @@ <h3>Algorithm</h3>
13091328
error has been detected and processing is aborted.</li>
13101329
<li>Otherwise, <a>previous context</a> was determined before,
13111330
and no further processing is necessary.</li>
1312-
</ol>
1331+
</ol></details>
13131332
</li>
13141333
<li>Create a <a class="changed">map</a> <var>defined</var> to keep
13151334
track of whether or not a <a>term</a> has already been defined

0 commit comments

Comments
 (0)