Skip to content

Commit 0ccdefd

Browse files
kfranqueirofstrr
andauthored
Converge on default pre > code highlight.js usage (#4604)
- Removes our customization of the highlight.js config - Adds `<code>` in cases where it is warranted but was missing - Intentionally does not change instances that are now fixed by resetting the configuration - Removes `no-highlight` and the `<code>` tag in its entirety in T1, T2, and T3, which don't need highlight.js to run at all - Copies and fixes references to the highlight.js script and theme for Understanding documents, so it will work for the code block in Understanding Conformance - Removes a duplicated `;` in a noembed example (spotted by Francis) Note: Silverlight and Flash techniques use only `<pre>`, but I left them alone, since they are all obsolete, and our build of highlight.js does not support e.g. C# and ActionScript anyway. --------- Co-authored-by: Francis Storr <[email protected]>
1 parent 568f662 commit 0ccdefd

File tree

18 files changed

+63
-57
lines changed

18 files changed

+63
-57
lines changed

_includes/waiscript.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
<link rel="stylesheet" href="../a11y-light.css">
2-
<script src="../highlight.min.js"></script>
1+
{% if isTechniques %}{% assign hljsPath = "../" %}{% endif %}
2+
<link rel="stylesheet" href="{{ hljsPath }}a11y-light.css">
3+
<script src="{{ hljsPath }}highlight.min.js"></script>
34
<script>
4-
hljs.configure({
5-
cssSelector: 'pre'
6-
});
75
hljs.highlightAll();
86
var translationStrings = {}; /* fix WAI JS */
97
</script>

eleventy.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,19 @@ export default async function (eleventyConfig: any) {
257257
let hasDisplayedGuidance = false;
258258
eleventyConfig.on("eleventy.after", async ({ dir, runMode }: EleventyEvent) => {
259259
// addPassthroughCopy can only map each file once,
260-
// but base.css needs to be copied to a 2nd destination
260+
// but some CSS files need to be copied to 2 destinations
261261
await copyFile(
262262
join(dir.input, "css", "base.css"),
263263
join(dir.output, "understanding", "base.css")
264264
);
265+
await copyFile(
266+
join(dir.input, "css", "a11y-light.css"),
267+
join(dir.output, "understanding", "a11y-light.css")
268+
);
269+
await copyFile(
270+
join(dir.input, "script", "highlight.min.js"),
271+
join(dir.output, "understanding", "highlight.min.js")
272+
);
265273

266274
// Output guidelines/index.html and dependencies for PR runs (not for GH Pages or W3C site)
267275
const sha = process.env.COMMIT_REF; // Read environment variable exposed by Netlify

techniques/client-side-script/SCR37.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ <h3>An options button that opens a dialog</h3>
2222
<p>The triggering element is a button and the script is triggered from the onclick event. This sends the appropriate events to the operating system so that assistive technology is aware of the change in the DOM. </p>
2323
<p>In this example, the Submit and Reset buttons inside the dialog simply hide the <code class="el">div</code>. </p>
2424

25-
<pre xml:space="preserve">...
25+
<pre><code>...
2626
&lt;button onclick="TogglePopup(event,true)"
2727
name="pop0001"&gt;Options&lt;/button&gt;
2828

@@ -42,11 +42,11 @@ <h3>An options button that opens a dialog</h3>
4242

4343
&lt;/div&gt;
4444
...
45-
</pre>
45+
</code></pre>
4646

4747
<p>The <code class="el">div</code>, heading and <code class="el">form</code> elements are styled with CSS to look like a dialog. </p>
4848

49-
<pre xml:space="preserve">...
49+
<pre><code>...
5050
a { color:blue; }
5151
a.clickPopup img { border:none; width:0; }
5252

@@ -59,11 +59,11 @@ <h3>An options button that opens a dialog</h3>
5959
#pop0001 div.buttons { text-align:right; }
6060
#pop0001 div.buttons input { width:6em; }
6161
...
62-
</pre>
62+
</code></pre>
6363

6464
<p>The script toggles the display of the popup <code class="el">div</code>, showing it and hiding it. </p>
6565

66-
<pre xml:space="preserve">...
66+
<pre><code>...
6767
function TogglePopup(evt,show) {
6868
HarmonizeEvent(evt);
6969
var src = evt.target;
@@ -102,7 +102,7 @@ <h3>An options button that opens a dialog</h3>
102102
return false;
103103
}
104104
...
105-
</pre>
105+
</code></pre>
106106

107107
</section>
108108
</section><section id="tests"><h2>Tests</h2>

techniques/css/C8.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ <h3>Increasing the spacing between characters in a word</h3>
2727

2828
<section id="the-css">
2929
<h4>The CSS</h4>
30-
<pre xml:space="preserve"><code class="language-css">h2 {
30+
<pre><code>h2 {
3131
letter-spacing: 1em;
3232
}</code></pre>
3333
</section>
3434

3535
<section id="the-html">
3636
<h4>The HTML</h4>
3737

38-
<pre xml:space="preserve"><code class="language-html">&lt;h2&gt;Museum&lt;/h2&gt;</code></pre>
38+
<pre><code class="language-html">&lt;h2&gt;Museum&lt;/h2&gt;</code></pre>
3939

4040
<p>The rendered result might look something like:</p>
4141

42-
<pre xml:space="preserve">M u s e u m</pre>
42+
<pre>M u s e u m</pre>
4343
</section>
4444
</section>
4545
</section>

techniques/general/G224.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h2>Examples</h2>
2424
<section class="example">
2525
<p>A website conveys information in a nested list format. The understandability of the list hierarchy is supported by the indentation of the list content. While it is important for the individual list item text to reflow, the list hierarchy would suffer if flattened so that all content would fit within a 320 CSS pixel wide viewport.</p>
2626
<p>The following example list contains additional nested lists to provide more context for each of the parent list item's text. To maintain the visual hierarchy, the indentation of each list level remains present, but modified once an author defined CSS breakpoint is met. Additional styles are set for different breakpoints to mitigate against the potential for content to extend beyond a 320px wide viewport, while accounting for visual spacing against the borders of the viewport, to attempt to make the content not feel cramped. At the smallest breakpoint, the content of list items receive a minimum width to mitigate against potentially "squished" content lists with many nested levels. At this breakpoint, each nested list level can be horizontally scrolled into view, and once a nested list is visible within the viewport, only vertical scrolling will be necessary to read the content of the nested list's items.</p>
27-
<pre>
27+
<pre><code>
2828
&lt;div class="example">
2929
&lt;ul>
3030
&lt;li>
@@ -55,8 +55,8 @@ <h2>Examples</h2>
5555
...
5656
&lt;/ul>
5757
&lt;/div>
58-
</pre>
59-
<pre>
58+
</code></pre>
59+
<pre><code>
6060
*, *::before, *::after {
6161
box-sizing: border-box;
6262
}
@@ -83,7 +83,7 @@ <h2>Examples</h2>
8383
min-width: 300px;
8484
}
8585
}
86-
</pre>
86+
</code></pre>
8787
<p>A working example of <a href="../../working-examples/reflow-nested-lists">a list where nested levels can be read within a 320px wide viewport</a>.</p>
8888
</section>
8989

@@ -92,7 +92,7 @@ <h2>Examples</h2>
9292
<p>As a user zooms in the web page, the CSS of the indentation can be adjusted to maintain this necessary structure, while also allowing more text to be visible on a single line.</p>
9393

9494
<p>The following represents a Python code example. The indentation of each line of text is necessary to create a group of statements that are executed as a block.</p>
95-
<pre>
95+
<pre><code>
9696
def complex_function(x):
9797
if x > 0:
9898
for i in range(x):
@@ -112,9 +112,9 @@ <h2>Examples</h2>
112112
print(f" {a} is odd")
113113
else:
114114
print("x is not a positive number")
115-
</pre>
115+
</code></pre>
116116
<p>The following code example demonstrates the use of indentation to convey the nesting of elements in an HTML document:</p>
117-
<pre>
117+
<pre><code>
118118
&lt;html lang=en>
119119
&lt;head>...&lt;/head>
120120
&lt;body>
@@ -123,9 +123,9 @@ <h2>Examples</h2>
123123
&lt;/div>
124124
&lt;/body>
125125
&lt;/html>
126-
</pre>
126+
</code></pre>
127127
<p>The indentation of code blocks like these could be adjusted at different viewport sizes, via a CSS Media Query.</p>
128-
<pre>
128+
<pre><code>
129129
@media screen and ( min-width: 320px ) {
130130
pre {
131131
tab-size: 8px;
@@ -143,7 +143,7 @@ <h2>Examples</h2>
143143
tab-size: 32px;
144144
}
145145
}
146-
</pre>
146+
</code></pre>
147147
<p>A working example of <a href="../../working-examples/reflow-indenting">code snippets using CSS to modify indentation width at different breakpoints</a>.
148148
</section>
149149
</section>

techniques/html/H35.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
</section><section id="examples"><h2>Examples</h2>
1717
<section class="example">
1818
<h3>An applet to play the tic-tac-toe game. </h3>
19-
<pre xml:space="preserve">&lt;applet code="tictactoe.class" width="250" height="250" alt="tic-tac-toe game"&gt;
19+
<pre><code>&lt;applet code="tictactoe.class" width="250" height="250" alt="tic-tac-toe game"&gt;
2020
tic-tac-toe game
21-
&lt;/applet&gt; </pre>
21+
&lt;/applet&gt;</code></pre>
2222
</section>
2323
</section><section id="tests"><h2>Tests</h2>
2424
<section class="procedure"><h3>Procedure</h3>

techniques/html/H4.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<code class="att">tabindex</code> attributes of the input fields are used to specify a tab
3535
order that navigates column by column.</p>
3636

37-
<pre xml:space="preserve">&lt;form action="#" method="post"&gt;
37+
<pre><code>&lt;form action="#" method="post"&gt;
3838
&lt;table summary="the first column contains the search criteria
3939
of the groom, the second column the search criteria of
4040
of the bride"&gt;
@@ -66,7 +66,7 @@
6666
title="Place of birth of the bride" tabindex="6"&gt;&lt;/td&gt;
6767
&lt;/tr&gt;
6868
&lt;/table&gt;
69-
&lt;/form&gt; </pre>
69+
&lt;/form&gt;</code></pre>
7070
</section>
7171
<section class="example">
7272

@@ -89,13 +89,13 @@
8989
a different number for each element. Then it is easy to rearrange those elements or
9090
add new elements and maintain a logical tab order.</p>
9191

92-
<pre xml:space="preserve"> &lt;a href="xxx" tabindex = "1"&gt;First link in list&lt;/a&gt;
92+
<pre><code>&lt;a href="xxx" tabindex = "1"&gt;First link in list&lt;/a&gt;
9393
&lt;a href="xxx" tabindex = "1"&gt;Second link in list&lt;/a&gt;
9494
&lt;a href="xxx" tabindex = "1"&gt;Link that was added long
9595
after the original list was created&lt;/a&gt;
9696
&lt;a href="xxx" tabindex = "1"&gt;Third link in list&lt;/a&gt;
9797
...
98-
&lt;a href="xxx" tabindex = "1"&gt;Twentieth link in list&lt;/a&gt; </pre>
98+
&lt;a href="xxx" tabindex = "1"&gt;Twentieth link in list&lt;/a&gt;</code></pre>
9999
</section>
100100
</section><section id="tests"><h2>Tests</h2>
101101
<section class="procedure"><h3>Procedure</h3>

techniques/html/H45.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
</section><section id="examples"><h2>Examples</h2>
1919
<section class="example">
2020
<h3>Using longdesc to refer to a long description contained on a separate resource.</h3>
21-
<pre xml:space="preserve">&lt;p&gt;&lt;img src="chart.gif" alt="a complex chart" longdesc="chartdesc.html"/&gt;&lt;/p&gt;</pre>
21+
<pre><code>&lt;p&gt;&lt;img src="chart.gif" alt="a complex chart" longdesc="chartdesc.html"/&gt;&lt;/p&gt;</code></pre>
2222
</section>
2323
<section class="example">
2424
<h3>Using longdesc to refer to a long description within the same page.</h3>
25-
<pre xml:space="preserve">&lt;img longdesc="thispage.html#desc" alt="Line graph of the number of subscribers" src="http://www.company/images/graph.png"&gt;
25+
<pre><code>&lt;img longdesc="thispage.html#desc" alt="Line graph of the number of subscribers" src="http://www.company/images/graph.png"&gt;
2626
&lt;div id="desc"&gt;
2727
&lt;h3&gt;Long Description: Line graph of the number of subscribers&lt;/h3&gt;
2828
&lt;!-- Full Description of Graph --&gt;
2929
&lt;p&gt;Long description ends.&lt;/p&gt;
30-
&lt;div&gt;</pre>
30+
&lt;div&gt;</code></pre>
3131
</section>
3232
</section><section id="tests"><h2>Tests</h2>
3333
<section class="procedure"><h3>Procedure</h3>

techniques/html/H46.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@
2121
<h3>
2222
<code class="el">noembed</code> is provided inside an <code class="el">embed</code>
2323
</h3>
24-
<pre xml:space="preserve">&lt;embed src="../movies/history_of_rome.mov"
24+
<pre><code>&lt;embed src="../movies/history_of_rome.mov"
2525
height="60" width="144" autostart="false"&gt;
2626
&lt;noembed&gt;
2727
&lt;a href="../transcripts/transcript_history_rome.htm"&gt;Transcript of "The history of Rome"&lt;/a&gt;
2828
&lt;/noembed&gt;
29-
&lt;/embed&gt;</pre>
29+
&lt;/embed&gt;</code></pre>
3030
</section>
3131
<section class="example">
3232
<h3>
3333
<code class="el">noembed</code> is provided beside an <code class="el">embed</code>
3434
</h3>
35-
<pre xml:space="preserve">&lt;embed src="moviename.swf" width="100" height="80"
35+
<pre><code>&lt;embed src="moviename.swf" width="100" height="80"
3636
pluginspage="http://example.com/shockwave/download/" /&gt;
3737
&lt;noembed&gt;
3838
&lt;img alt="Still from Movie" src="moviename.gif"
3939
width="100" height="80" /&gt;
40-
&lt;/noembed&gt;;</pre>
40+
&lt;/noembed&gt;</code></pre>
4141
</section>
4242
</section><section id="tests"><h2>Tests</h2>
4343
<section class="procedure"><h3>Procedure</h3>

techniques/html/H56.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h3>Defining the text direction of a nested, mixed-direction phrase, in Hebrew a
3333
<p>the title is "YTIVITCA NOITAZILANOITANRETNI, w3c" in hebrew.</p>
3434
<p>The following markup will produce the expected result:</p>
3535

36-
<pre xml:space="preserve">&lt;p&gt;The title says "&lt;span lang="he" dir="rtl"&gt;פעילות הבינאום, W3C&lt;/span&gt;" in Hebrew.&lt;/p&gt;</pre>
36+
<pre><code>&lt;p&gt;The title says "&lt;span lang="he" dir="rtl"&gt;פעילות הבינאום, W3C&lt;/span&gt;" in Hebrew.&lt;/p&gt;</code></pre>
3737
</section>
3838
</section>
3939
<section id="tests">

0 commit comments

Comments
 (0)