Skip to content

Commit 11223a3

Browse files
committed
Add missing hljs class overrides + build check
1 parent ad4542f commit 11223a3

39 files changed

+75
-59
lines changed

11ty/CustomLiquid.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,22 @@ export class CustomLiquid extends Liquid {
153153
// Add charset to pages that forgot it
154154
if (!$("meta[charset]").length) $('<meta charset="UTF-8">').prependTo("head");
155155

156+
const $missingHljsOverrides = $("pre code:not([class])");
157+
if ($missingHljsOverrides.length) {
158+
$missingHljsOverrides.each((_, el) => {
159+
const code = $(el).html()!.replace(/\n/g, "\\n");
160+
const excerpt = `${code.slice(0, 40)}${code.length > 40 ? "..." : ""}`;
161+
console.log(
162+
`${filepath} missing "language-*" or "no-highlight" class on <pre><code> starting with ${excerpt}`
163+
);
164+
});
165+
if (process.env.ELEVENTY_RUN_MODE === "build") {
166+
throw new Error(
167+
"Please ensure all code blocks have a highlight.js class (language-* or no-highlight)."
168+
);
169+
}
170+
}
171+
156172
const prependedIncludes = ["header"];
157173
const appendedIncludes = ["wai-site-footer", "site-footer"];
158174

techniques/aria/ARIA24.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ <h5><strong>- Instead of... -</strong></h5>
7979
</section>
8080
<section>
8181
<h5><strong>- Do... -</strong></h5>
82-
<pre xml:space="preserve"><code>&lt;p&gt;
82+
<pre><code class="language-html">&lt;p&gt;
8383
&lt;span class=&quot;icon icon-star-bg&quot; role=&quot;img&quot; aria-label=&quot;Favorite&quot;&gt;&lt;/span&gt;
8484
&lt;/p&gt;</code></pre>
8585
</section>

techniques/client-side-script/SCR37.html

Lines changed: 3 additions & 3 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>div</code>. </p>
2424

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

@@ -46,7 +46,7 @@ <h3>An options button that opens a dialog</h3>
4646

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

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

@@ -63,7 +63,7 @@ <h3>An options button that opens a dialog</h3>
6363

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

66-
<pre><code>...
66+
<pre><code class="language-javascript">...
6767
function TogglePopup(evt,show) {
6868
HarmonizeEvent(evt);
6969
var src = evt.target;

techniques/css/C15.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h3>Link elements</h3>
4848
<h3>Highlighting elements that receive focus</h3>
4949
<p>In this example, the :focus pseudo-class is used to change the style applied to input fields when they receive focus by changing the background color.</p>
5050

51-
<pre xml:space="preserve"><code class="language-">&lt;!doctype html&gt;
51+
<pre><code class="language-html">&lt;!doctype html&gt;
5252
&lt;html lang="en"&gt;
5353
&lt;head&gt;
5454
&lt;style&gt;

techniques/css/C43.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h3>Using CSS <code>scroll-padding</code> to un-obscure content</h3>
3030
<p>This example demonstrates a technique to un-obscure content underneath a fixed-position banner. To prevent the page becoming unusable at smaller screen sizes, the banner becomes un-fixed. To observe the <code>scroll-padding</code> effect you will need to use a viewport over 800px wide.</p>
3131
</aside>
3232
<p>Working example: <a href="../../working-examples/css-padding-focus-not-obscured/">Using CSS <code>scroll-padding</code> to un-obscure content</a>.</p>
33-
<pre xml:space="preserve"><code>&lt;!doctype html&gt;
33+
<pre><code class="language-html">&lt;!doctype html&gt;
3434
&lt;html lang="en"&gt;
3535
&lt;head&gt;
3636
&lt;meta charset="utf-8"&gt;

techniques/css/C45.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h3>Using <abbr title="Cascading Style Sheets">CSS</abbr> <code>:focus-visible</
3636
<p>By default, in all modern browsers, this button does not show any focus indication when activated using a mouse/pointer. Browsers show their default focus outline/indication when a user sets focus on the button using <kbd>Tab</kbd>.</p>
3737
<p>In order to make this focus indication more prominent, we use the <code>:focus-visible</code> pseudo-class selector to define a more intentional and pronounced focus style.</p>
3838
<p>Working example: <a href="../../working-examples/css-focus-visible/">Using CSS <code>:focus-visible</code> to provide keyboard focus indication</a>.</p>
39-
<pre><code>&lt;!DOCTYPE html&gt;
39+
<pre><code class="language-html">&lt;!DOCTYPE html&gt;
4040
&lt;html lang="en"&gt;
4141
&lt;head&gt;
4242
&lt;meta charset="utf-8"&gt;

techniques/css/C8.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ <h3>Increasing the spacing between characters in a word</h3>
2727

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

techniques/failures/F111.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h2>Examples</h2>
3030
<section class="example">
3131
<h3>A text input with a visible label, but without an accessible name</h3>
3232
<p>The text input is preceded by a visible text label "Enter name", but the text is not marked up as a <code>&lt;label&gt;</code> for the input, and there is no alternative way (e.g., <code>aria-label</code>) to provide the input with an accessible name at all.</p>
33-
<pre><code>
33+
<pre><code class="language-html">
3434
&lt;p&gt;Enter name&lt;/p&gt;
3535
&lt;input type="text"&gt;
3636
</code></pre>
@@ -39,7 +39,7 @@ <h3>A text input with a visible label, but without an accessible name</h3>
3939
<section class="example">
4040
<h3>A text input with a visible label and aria-labelledby pointing to a non-existent id</h3>
4141
<p>The text input is preceded by a visible text label "Enter name". The text's container has an <code>id</code> of <code>nameEntry</code>, but the input has an <code>aria-labelledby</code> referencing a non-existent <code>name-entry</code> <code>id</code>. As a result, the input lacks an accessible name altogether.</p>
42-
<pre><code>
42+
<pre><code class="language-html">
4343
&lt;p id="nameEntry"&gt;Enter name&lt;/p&gt;
4444
&lt;input type="text" aria-labelledby="name-entry" &gt;
4545
</code></pre>

techniques/failures/F71.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ <h3>Characters </h3>
1212

1313
<p>The following word looks, in browsers with appropriate font support, like the English word "cook", yet is composed of the string <code>U+03f2 U+043E U+03BF U+006B</code>, only one of which is a letter from the Western alphabet. This word will not be processed meaningfully, and a text alternative is not provided.</p>
1414

15-
<pre xml:space="preserve"><code>ϲоοk</code></pre>
15+
<pre>ϲоοk</pre>
1616
</section>
1717
<section class="example">
1818
<h3>Character entities</h3>
1919

2020
<p>The following example, like its predecessor, will look like the English word "cook" when rendered in browsers with appropriate font support. In this case, the characters are implemented with character entities, but the word will still not be processed meaningfully, and a text alternative is not provided.</p>
2121

22-
<pre xml:space="preserve"><code>&amp;#x03F2;&amp;#x043E;&amp;#x03BF;&amp;#x006B;</code></pre>
22+
<pre><code class="language-html">&amp;#x03F2;&amp;#x043E;&amp;#x03BF;&amp;#x006B;</code></pre>
2323

2424
<p>Working Example: "ϲоοk"</p>
2525

techniques/general/G224.html

Lines changed: 5 additions & 5 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><code>
27+
<pre><code class="language-html">
2828
&lt;div class="example">
2929
&lt;ul>
3030
&lt;li>
@@ -56,7 +56,7 @@ <h2>Examples</h2>
5656
&lt;/ul>
5757
&lt;/div>
5858
</code></pre>
59-
<pre><code>
59+
<pre><code class="language-css">
6060
*, *::before, *::after {
6161
box-sizing: border-box;
6262
}
@@ -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><code>
95+
<pre><code class="language-python">
9696
def complex_function(x):
9797
if x > 0:
9898
for i in range(x):
@@ -114,7 +114,7 @@ <h2>Examples</h2>
114114
print("x is not a positive number")
115115
</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><code>
117+
<pre><code class="language-html">
118118
&lt;html lang=en>
119119
&lt;head>...&lt;/head>
120120
&lt;body>
@@ -125,7 +125,7 @@ <h2>Examples</h2>
125125
&lt;/html>
126126
</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><code>
128+
<pre><code class="language-css">
129129
@media screen and ( min-width: 320px ) {
130130
pre {
131131
tab-size: 8px;

0 commit comments

Comments
 (0)