-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathsrc.html
More file actions
436 lines (424 loc) · 17.2 KB
/
src.html
File metadata and controls
436 lines (424 loc) · 17.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
<!DOCTYPE html>
<!--
The source for this document is at:
https://github.com/speced/respec-web-services/blob/main/static/docs/src.html
-->
<html>
<head>
<meta charset="utf-8" />
<meta name="color-scheme" content="light dark">
<title>ReSpec Documentation</title>
<script
src="https://www.w3.org/Tools/respec/respec-w3c"
class="remove"
defer
></script>
<script class="remove">
var respecConfig = {
edDraftURI: null,
editors: [
{
name: "ReSpec",
url: "https://github.com/speced/respec",
},
],
lint: {
"no-http-props": false,
"check-punctuation": true,
},
preProcess: [addSectionIds, fixIncludes],
postProcess: [
fixLinks,
addWikiLinks,
fixMarkupPostprocess,
postProcessEnhance,
cleanup,
],
monetization: {
removeOnSave: false,
},
logos: [
{
src: "/respec-logo.png",
alt: "ReSpec logo",
height: 120,
url: "https://respec.org/",
},
],
canonicalURI: "https://respec.org/docs/",
github: "speced/respec",
otherLinks: [
{
key: "Edit this documentation",
data: [
{
value: "GitHub Wiki",
href: "https://github.com/speced/respec/wiki",
},
{
value: "Single Page",
href: "https://github.com/speced/respec-web-services/blob/main/static/docs/src.html",
},
],
},
],
};
function addSectionIds() {
const sections = document.querySelectorAll(
"section[data-include]:not([id])",
);
for (const section of sections) {
section.id = section.dataset.include;
}
}
function fixIncludes() {
for (const section of document.querySelectorAll(
"section[data-include]",
)) {
const { include } = section.dataset;
Object.assign(section.dataset, {
includeName: include,
includeFormat: "markdown",
oninclude: "fixMarkupOnInclude",
// TODO: update URL on migration to speced org
include: `https://raw.githubusercontent.com/wiki/speced/respec/${include}.md`,
});
if (!section.hasAttribute("data-max-toc")) {
section.dataset.maxToc = section.querySelector("section")
? "2"
: "1";
}
}
}
/**
* @param {*} _
* @param {string} content
*/
function fixMarkupOnInclude(_, content) {
const ZERO_WIDTH_SPACE = "​";
// Escape [[[foo]]] and [[foo]] by adding zero-width space. We remove these
// extraneous characters in postProcess, so users don't end up copy pasting
// them. Ugly, but other way is upstream changes for an extreme edge case.
content = content
.replace(/\[\[/g, `[${ZERO_WIDTH_SPACE}[${ZERO_WIDTH_SPACE}`)
// Similarly for [= term =], {{ term }}, [^elem^]
.replace(/\[=/g, `[${ZERO_WIDTH_SPACE}=`)
.replace(/{{/g, `{${ZERO_WIDTH_SPACE}{`)
.replace(/\[\^/g, `[${ZERO_WIDTH_SPACE}^`)
// and also escape | used for inline variables
.replace(/\`\\\|(\w+)/g, `\`\\|${ZERO_WIDTH_SPACE}$1`)
.replace(/(\w+)\\\|\`/g, `$1${ZERO_WIDTH_SPACE}\\|\``)
.replace(/\`\|(\w+)/g, `\`\\|${ZERO_WIDTH_SPACE}$1`)
.replace(/(\w+)\|\`/g, `$1${ZERO_WIDTH_SPACE}\\|\``);
// Add .note and .advisement classes based on line prefix
content = content
.split("\n")
.map(line => {
if (/^.{0,5}\s*Warning:/.test(line))
return `<div class="advisement">\n\n${line}</div>`;
if (/^.{0,5}\s*Note:/.test(line))
return `<div class="note">\n\n${line}</div>`;
return line;
})
.join("\n");
return content;
}
function fixMarkupPostprocess() {
for (const elem of document.querySelectorAll("code")) {
if (elem.innerHTML.includes("&#8203;")) {
elem.innerHTML = elem.innerHTML.replace(/&#8203;/g, "");
}
if (elem.innerHTML.includes("\\|")) {
elem.innerHTML = elem.innerHTML.replace(/\\\|/g, "|");
}
}
}
function postProcessEnhance() {
for (const elem of document.querySelectorAll("section dl, table")) {
elem.classList.add("def");
}
}
function fixLinks() {
/** @type {NodeListOf<HTMLAnchorElement>} */
const anchors = document.querySelectorAll(
"section a:not([href^=http]):not([href^='mailto:']):not([href^='#'])",
);
for (const a of anchors) {
const href = a.hash ? a.hash.slice(1) : a.pathname.split("/").pop();
if (document.getElementById(href)) {
a.href = `#${href}`;
} else if (document.getElementById(`id-${href}`)) {
// Special section IDs like "conformance" trigger ReSpec's "include"
// behaviour. We manually add `id-` prefix to overcome that.
a.href = `#id-${href}`;
} else if (document.querySelector(`[data-include-name="${href}"]`)) {
const { id } = document.querySelector(
`[data-include-name="${href}"]`,
);
a.href = `#${id}`;
} else {
// TODO: update URL on migration to speced org
a.href = `https://github.com/speced/respec/wiki/${href}`;
}
}
}
function addWikiLinks() {
const createWikiLink = includeName => {
const wikiLink = document.createElement("a");
// TODO: update URL on migration to speced org
wikiLink.href = `https://github.com/speced/respec/wiki/${includeName}/_edit`;
const title = "Edit this section on Wiki";
wikiLink.title = title;
wikiLink.setAttribute("aria-label", title);
wikiLink.textContent = "📝 Edit";
wikiLink.classList.add("wiki-link");
return wikiLink;
};
for (const section of document.querySelectorAll("section")) {
const closest = section.closest("section[data-include-name]");
if (!closest) continue;
const { includeName } = closest.dataset;
const wikiLink = createWikiLink(includeName);
section.querySelector("h2, h3, h4, h5, h6").append(wikiLink);
}
}
function cleanup() {
const attributesToRemove = [
"data-max-toc",
"data-include-name",
"data-oninclude",
];
const selector = attributesToRemove.map(attr => `[${attr}]`).join(", ");
document.querySelectorAll(selector).forEach(el => {
attributesToRemove.forEach(attr => el.removeAttribute(attr));
});
document.getElementById("respec-dfn-panel").remove();
}
</script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<section id="abstract">
<p>
ReSpec makes it easier to write technical documents. It was originally
designed for writing W3C specifications, but now supports many output
formats.
</p>
</section>
<section data-max-toc="3" data-include-name="ReSpec-Editor's-Guide">
<h2>Getting Started</h2>
<section
data-include="ReSpec-Editor's-Guide"
data-include-replace="true"
></section>
<section data-max-toc="1" data-include="WebIDL-Guide"></section>
</section>
<section data-max-toc="2" data-include="static-snapshots"></section>
<section data-max-toc="2" data-include="Shorthands-Guide"></section>
<section data-max-toc="1" data-include="markdown"></section>
<section>
<h2>Configuration Options</h2>
<section data-include="addSectionLinks"></section>
<section data-include="authors"></section>
<section data-include="caniuse"></section>
<section data-include="edDraftURI"></section>
<section data-include="editors"></section>
<section data-include="format"></section>
<section data-include="formerEditors"></section>
<section data-include="github"></section>
<section data-include="highlightVars"></section>
<section data-include="implementationStatus"></section>
<section data-include="isPreview"></section>
<section data-include="license"></section>
<section data-include-name="lint" data-max-toc="2">
<section data-include="lint" data-include-replace="true"></section>
<section data-include="a11y"></section>
<section data-include="check-charset"></section>
<section data-include="check-internal-slots"></section>
<section data-include="check-punctuation"></section>
<section data-include="informative-dfn"></section>
<section data-include="local-refs-exist"></section>
<section data-include="no-captionless-tables"></section>
<section data-include="no-headingless-sections"></section>
<section data-include="no-http-props"></section>
<section data-include="no-unused-dfns"></section>
<section data-include="no-unused-vars"></section>
<section data-include="privsec-section"></section>
<section data-include="wpt-tests-exist"></section>
</section>
<section data-include="localBiblio"></section>
<section data-include="logos"></section>
<section data-include="maxTocLevel"></section>
<section data-include="mdn"></section>
<section data-include="modificationDate"></section>
<section data-include="monetization"></section>
<section data-include="noTOC"></section>
<section data-include="otherLinks"></section>
<section data-include="pluralize"></section>
<section data-include="postProcess"></section>
<section data-include="preProcess"></section>
<section data-include="publishDate"></section>
<section data-include="shortName"></section>
<section data-include="specStatus"></section>
<section data-include="subjectPrefix"></section>
<section data-include="subtitle"></section>
<section data-include="testSuiteURI"></section>
<section data-include="xref"></section>
</section>
<section>
<h2>W3C Specific Configuration Options</h2>
<section data-include="additionalCopyrightHolders"></section>
<section data-include="alternateFormats"></section>
<section data-include="canonicalURI"></section>
<section data-include="charterDisclosureURI"></section>
<section data-include="copyrightStart"></section>
<section data-include="crEnd"></section>
<section data-include="doJsonLd"></section>
<section data-include="errata"></section>
<section data-include="group"></section>
<section data-include="implementationReportURI"></section>
<section data-include="latestVersion"></section>
<section data-include="level"></section>
<section data-include="noRecTrack"></section>
<section data-include="prEnd"></section>
<section data-include="prevED"></section>
<section data-include="previousDiffURI"></section>
<section data-include="previousMaturity"></section>
<section data-include="previousPublishDate"></section>
<section data-include="prevRecShortname"></section>
<section data-include="prevRecURI"></section>
<section data-include="submissionCommentNumber"></section>
<section data-include="wgPublicList"></section>
</section>
<section id="special-section-ids">
<h2>Special `<section>` IDs</h2>
<section id="id-conformance" data-include="conformance"></section>
<section id="id-gh-contributors" data-include="gh-contributors"></section>
<section id="id-idl-index" data-include="idl-index"></section>
<section id="id-index" data-include="index"></section>
<section id="id-issue-summary" data-include="issue-summary"></section>
<section id="id-references" data-include="references"></section>
<section id="id-tof" data-include="tof"></section>
</section>
<section>
<h2>Special element behaviour</h2>
<section data-include="dark-mode"></section>
<section data-include="figure"></section>
<section data-include="h1-element"></section>
<section data-include="pre-and-code-elements"></section>
<section data-include="section"></section>
<section data-include="title-element"></section>
</section>
<section>
<h2>CSS classes</h2>
<section data-include="appendix"></section>
<section data-include="ednote"></section>
<section data-include="example"></section>
<section data-include="exclude"></section>
<section data-include="data-export"></section>
<section data-include="informative"></section>
<section data-include="issue"></section>
<section data-include="lint-ignore"></section>
<section data-include="no-link-warnings"></section>
<section data-include="nohighlight"></section>
<section data-include="nolinks"></section>
<section data-include="note"></section>
<section data-include="notoc-class"></section>
<section data-include="numbered"></section>
<section data-include="override"></section>
<section data-include="permission"></section>
<section data-include="practice"></section>
<section data-include="practicedesc"></section>
<section data-include="practicelab"></section>
<section data-include="remove"></section>
<section data-include="removeOnSave"></section>
<section data-include="warning"></section>
<section>
<h3>W3C Specific</h3>
<section data-include="updateable-rec" id="updateable-rec-class"></section>
</section>
</section>
<section>
<h2>HTML Attributes</h2>
<section data-include="data-abbr"></section>
<section data-include="data-cite"></section>
<section data-include="data-dfn-for"></section>
<section data-include="data-dfn-type"></section>
<section data-include="data-format"></section>
<section data-include="data-include"></section>
<section data-include="data-include-format"></section>
<section data-include="data-include-replace"></section>
<section data-include="data-link-for"></section>
<section data-include="data-link-type"></section>
<section data-include="data-local-lt"></section>
<section data-include="data-lt"></section>
<section data-include="data-lt-no-plural"></section>
<section data-include="data-lt-noDefault"></section>
<section data-include="data-max-toc"></section>
<section data-include="data-number"></section>
<section data-include="data-oninclude"></section>
<section data-include="data-sort"></section>
<section data-include="data-tests"></section>
<section data-include="data-type"></section>
<section data-include="dir"></section>
<section data-include="lang"></section>
</section>
<section>
<h2>Custom Elements</h2>
<section data-include="rs-changelog"></section>
</section>
<section>
<h2>Special properties</h2>
<section data-include="document.respec"></section>
</section>
<section>
<h2>Deprecated Options</h2>
<section data-include="addPatentNote"></section>
<section data-include="processVersion"></section>
<section data-include="tocIntroductory"></section>
<section data-include="wg"></section>
<section data-include="wgId"></section>
<section data-include="wgPatentURI"></section>
<section data-include="wgURI"></section>
</section>
<section class="appendix" data-include="Ecosystem"></section>
<section class="appendix" data-include="person"></section>
<section class="appendix" data-max-toc="1" data-include-name="Errors-FAQ">
<h2>Common Errors</h2>
<section data-include="Errors-FAQ" data-include-replace="true"></section>
</section>
<section class="appendix" data-max-toc="2">
<h2>Developers Guide</h2>
<section data-include="Developers-Guide" data-include-replace="true"></section>
</section>
<section>
<h2>Editing this document</h2>
<p>
This document is generated directly from the content of the
<a href="https://github.com/speced/respec/wiki">ReSpec project wiki</a> on
GitHub. Thus, it can be edited in two ways:
</p>
<ol>
<li>
The
<a
href="https://github.com/speced/respec-web-services/edit/main/static/docs/src.html"
>src.html</a
>
for this document provides the structure. The `src.html` is available
in the
<a href="https://github.com/speced/respec-web-services"
>respec-web-services repository</a
>.
</li>
<li>
The
<a href="https://github.com/speced/respec/wiki">ReSpec project wiki</a>.
In addition, hovering over a section heading provides a link to
directly edit the relevant page in the wiki.
</li>
</ol>
</section>
<section id="conformance" class="removeOnSave"></section>
</body>
</html>