numbered highlights explanation
This commit is contained in:
parent
df320adcf5
commit
fff72dff15
|
@ -25,13 +25,58 @@ Note that the syntax highlighting uses a greyscale theme. **Infusion** is carefu
|
||||||
To preserve the wrapping inside code blocks, horizontal scrolling is implemented. To make sure scrolling is keyboard accessible, code blocks are focusable. An `aria-label` is provided to identify the code block to screen reader users.
|
To preserve the wrapping inside code blocks, horizontal scrolling is implemented. To make sure scrolling is keyboard accessible, code blocks are focusable. An `aria-label` is provided to identify the code block to screen reader users.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
## Annotated
|
## Annotated HTML
|
||||||
|
|
||||||
|
Since the structure of HTML is critical to interoperable web interfaces, **Infusion** offers the ability to highlight and annotate specific HTML elements and attributes using the `html` shortcode.
|
||||||
|
|
||||||
|
Take an accessible dialog. You may wish to point out key attributes that make that dialog support assistive technologies:
|
||||||
|
|
||||||
{{<html>}}
|
{{<html>}}
|
||||||
<ul>
|
<div ((role="dialog")) ((aria-labelledby="dialog-heading"))>
|
||||||
<li>Here's a thing</li>
|
<button ((aria-label="close"))>x</button>
|
||||||
<li ((role="separator"))>Here's a thing</li>
|
<h2 ((id="dialog-heading"))>Confirmation</h2>
|
||||||
<li>Here's a ((thing))</li>
|
<p>Press <strong>Okay</strong> to confirm or <strong>Cancel</strong></p>
|
||||||
<li>Here's a thing <span ((aria-hidden="true"))></span></li>
|
<button>Okay</button>
|
||||||
</ul>
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
{{</html>}}
|
{{</html>}}
|
||||||
|
|
||||||
|
You mark out the highlighted areas with double parentheses like so:
|
||||||
|
|
||||||
|
{{<codeBlock>}}
|
||||||
|
{{<html>}}
|
||||||
|
<div ((role="dialog")) ((aria-labelledby="dialog-heading"))>
|
||||||
|
<button ((aria-label="close"))>x</button>
|
||||||
|
<h2 ((id="dialog-heading"))>Confirmation</h2>
|
||||||
|
<p>Press <strong>Okay</strong> to confirm or <strong>Cancel</strong></p>
|
||||||
|
<button>Okay</button>
|
||||||
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
|
{{</html>}}
|
||||||
|
{{</codeBlock>}}
|
||||||
|
|
||||||
|
Better still, if you include `numbered="true"`, each highlight is enumberated so you can reference it directly in the ensuing text.
|
||||||
|
|
||||||
|
{{<html numbered="true">}}
|
||||||
|
<div ((role="dialog")) ((aria-labelledby="dialog-heading"))>
|
||||||
|
<button ((aria-label="close"))>x</button>
|
||||||
|
<h2 ((id="dialog-heading"))>Confirmation</h2>
|
||||||
|
<p>Press <strong>Okay</strong> to confirm or <strong>Cancel</strong></p>
|
||||||
|
<button>Okay</button>
|
||||||
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
|
{{</html>}}
|
||||||
|
|
||||||
|
You just include `numbered="true"` on the opening shortcode tag:
|
||||||
|
|
||||||
|
{{<codeBlock>}}
|
||||||
|
{{<html numbered="true">}}
|
||||||
|
<div ((role="dialog")) ((aria-labelledby="dialog-heading"))>
|
||||||
|
<button ((aria-label="close"))>x</button>
|
||||||
|
<h2 ((id="dialog-heading"))>Confirmation</h2>
|
||||||
|
<p>Press <strong>Okay</strong> to confirm or <strong>Cancel</strong></p>
|
||||||
|
<button>Okay</button>
|
||||||
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
|
{{</html>}}
|
||||||
|
{{</codeBlock>}}
|
||||||
|
|
|
@ -65,8 +65,10 @@ figure p img {
|
||||||
[data-expands]:focus svg,
|
[data-expands]:focus svg,
|
||||||
.patterns a:focus .text,
|
.patterns a:focus .text,
|
||||||
[for="themer"] :focus + [aria-hidden] {
|
[for="themer"] :focus + [aria-hidden] {
|
||||||
outline: 3px solid #888;
|
outline: 4px solid #999;
|
||||||
outline-offset: 2px;
|
}
|
||||||
|
a {
|
||||||
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
/* fix for IE :( */
|
/* fix for IE :( */
|
||||||
|
|
||||||
|
@ -382,7 +384,7 @@ caption {
|
||||||
}
|
}
|
||||||
#menu-button:focus {
|
#menu-button:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
box-shadow: inset 0 0 0 0.25rem #888;
|
box-shadow: inset 0 0 0 0.25rem #999;
|
||||||
}
|
}
|
||||||
/* Tables of contents */
|
/* Tables of contents */
|
||||||
|
|
||||||
|
@ -522,37 +524,30 @@ pre[class*=language-] code * {
|
||||||
margin-top: -1rem;
|
margin-top: -1rem;
|
||||||
}
|
}
|
||||||
.html-annotated {
|
.html-annotated {
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
padding: 1.5rem;
|
padding: 1.5rem;
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
counter-reset: annotation;
|
counter-reset: annotation;
|
||||||
}
|
}
|
||||||
.highlight {
|
.highlight {
|
||||||
background: #ddd;
|
background: #ddd;
|
||||||
padding: 0.25rem 0.5rem;
|
padding: 0.0625rem 0.33rem;
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
}
|
}
|
||||||
.highlight::after {
|
.numbered .highlight::after {
|
||||||
counter-increment: annotation;
|
counter-increment: annotation;
|
||||||
content: counter(annotation);
|
content: counter(annotation);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 0.5rem;
|
font-size: 0.5rem;
|
||||||
background: #111;
|
background: #111;
|
||||||
color: #fefefe;
|
color: #fefefe;
|
||||||
display: inline-block;
|
border-radius: 1rem;
|
||||||
width: 0.75rem;
|
margin-left: 0.25rem;
|
||||||
height: 0.75rem;
|
padding: 0.125em 0.5em;
|
||||||
line-height: 0.75rem;
|
vertical-align: 0.33em;
|
||||||
text-align: center;
|
|
||||||
border-radius: 1rem;
|
|
||||||
vertical-align: middle;
|
|
||||||
margin-left: 0.25rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*main {
|
/*main {
|
||||||
display: block;
|
display: block;
|
||||||
counter-reset: fig;
|
counter-reset: fig;
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
|
|
||||||
/* Enable scrolling by keyboard of code samples */
|
/* Enable scrolling by keyboard of code samples */
|
||||||
(function () {
|
(function () {
|
||||||
var codeBlocks = document.querySelectorAll('pre');
|
var codeBlocks = document.querySelectorAll('pre, .html-annotated');
|
||||||
|
|
||||||
Array.prototype.forEach.call(codeBlocks, function (block) {
|
Array.prototype.forEach.call(codeBlocks, function (block) {
|
||||||
if (block.querySelector('code')) {
|
if (block.querySelector('code')) {
|
||||||
|
|
|
@ -425,21 +425,74 @@
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
|
||||||
<h2 id="annotated">Annotated</h2>
|
<h2 id="annotated-html">Annotated HTML</h2>
|
||||||
|
|
||||||
|
<p>Since the structure of HTML is critical to interoperable web interfaces, <strong>Infusion</strong> offers the ability to highlight and annotate specific HTML elements and attributes using the <code>html</code> shortcode.</p>
|
||||||
|
|
||||||
|
<p>Take an accessible dialog. You may wish to point out key attributes that make that dialog support assistive technologies:</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="html-annotated"><code>
|
|
||||||
<ul>
|
<div class="html-annotated "><code>
|
||||||
<li>Here's a thing</li>
|
<div <span class='highlight'>role="dialog"</span> <span class='highlight'>aria-labelledby="dialog-heading"</span>>
|
||||||
<li <span class='highlight'>role="separator"</span>>Here's a thing</li>
|
<button <span class='highlight'>aria-label="close"</span>>x</button>
|
||||||
<li>Here's a <span class='highlight'>thing</span></li>
|
<h2 <span class='highlight'>id="dialog-heading"</span>>Confirmation</h2>
|
||||||
<li>Here's a thing <span <span class='highlight'>aria-hidden="true"</span>></span></li>
|
<p>Press <strong>Okay</strong> to confirm or <strong>Cancel</strong></p>
|
||||||
</ul>
|
<button>Okay</button>
|
||||||
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
</code></div>
|
</code></div>
|
||||||
|
|
||||||
|
|
||||||
|
<p>You mark out the highlighted areas with double parentheses like so:</p>
|
||||||
|
|
||||||
|
<pre class=""><code data-codeblock-shortcode>
|
||||||
|
{{<html>}}
|
||||||
|
<div ((role="dialog")) ((aria-labelledby="dialog-heading"))>
|
||||||
|
<button ((aria-label="close"))>x</button>
|
||||||
|
<h2 ((id="dialog-heading"))>Confirmation</h2>
|
||||||
|
<p>Press <strong>Okay</strong> to confirm or <strong>Cancel</strong></p>
|
||||||
|
<button>Okay</button>
|
||||||
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
|
{{</html>}}
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
|
||||||
|
<p>Better still, if you include <code>numbered="true"</code>, each highlight is enumberated so you can reference it directly in the ensuing text.</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="html-annotated numbered"><code>
|
||||||
|
<div <span class='highlight'>role="dialog"</span> <span class='highlight'>aria-labelledby="dialog-heading"</span>>
|
||||||
|
<button <span class='highlight'>aria-label="close"</span>>x</button>
|
||||||
|
<h2 <span class='highlight'>id="dialog-heading"</span>>Confirmation</h2>
|
||||||
|
<p>Press <strong>Okay</strong> to confirm or <strong>Cancel</strong></p>
|
||||||
|
<button>Okay</button>
|
||||||
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
|
</code></div>
|
||||||
|
|
||||||
|
|
||||||
|
<p>You just include <code>numbered="true"</code> on the opening shortcode tag:</p>
|
||||||
|
|
||||||
|
<pre class=""><code data-codeblock-shortcode>
|
||||||
|
{{<html numbered="true">}}
|
||||||
|
<div ((role="dialog")) ((aria-labelledby="dialog-heading"))>
|
||||||
|
<button ((aria-label="close"))>x</button>
|
||||||
|
<h2 ((id="dialog-heading"))>Confirmation</h2>
|
||||||
|
<p>Press <strong>Okay</strong> to confirm or <strong>Cancel</strong></p>
|
||||||
|
<button>Okay</button>
|
||||||
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
|
{{</html>}}
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<footer role="contentinfo">
|
<footer role="contentinfo">
|
||||||
|
|
|
@ -1709,21 +1709,74 @@ toc = false
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
|
||||||
<h2 id="annotated">Annotated</h2>
|
<h2 id="annotated-html">Annotated HTML</h2>
|
||||||
|
|
||||||
|
<p>Since the structure of HTML is critical to interoperable web interfaces, <strong>Infusion</strong> offers the ability to highlight and annotate specific HTML elements and attributes using the <code>html</code> shortcode.</p>
|
||||||
|
|
||||||
|
<p>Take an accessible dialog. You may wish to point out key attributes that make that dialog support assistive technologies:</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="html-annotated"><code>
|
|
||||||
<ul>
|
<div class="html-annotated "><code>
|
||||||
<li>Here's a thing</li>
|
<div <span class='highlight'>role="dialog"</span> <span class='highlight'>aria-labelledby="dialog-heading"</span>>
|
||||||
<li <span class='highlight'>role="separator"</span>>Here's a thing</li>
|
<button <span class='highlight'>aria-label="close"</span>>x</button>
|
||||||
<li>Here's a <span class='highlight'>thing</span></li>
|
<h2 <span class='highlight'>id="dialog-heading"</span>>Confirmation</h2>
|
||||||
<li>Here's a thing <span <span class='highlight'>aria-hidden="true"</span>></span></li>
|
<p>Press <strong>Okay</strong> to confirm or <strong>Cancel</strong></p>
|
||||||
</ul>
|
<button>Okay</button>
|
||||||
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
</code></div>
|
</code></div>
|
||||||
|
|
||||||
|
|
||||||
|
<p>You mark out the highlighted areas with double parentheses like so:</p>
|
||||||
|
|
||||||
|
<pre class=""><code data-codeblock-shortcode>
|
||||||
|
{{<html>}}
|
||||||
|
<div ((role="dialog")) ((aria-labelledby="dialog-heading"))>
|
||||||
|
<button ((aria-label="close"))>x</button>
|
||||||
|
<h2 ((id="dialog-heading"))>Confirmation</h2>
|
||||||
|
<p>Press <strong>Okay</strong> to confirm or <strong>Cancel</strong></p>
|
||||||
|
<button>Okay</button>
|
||||||
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
|
{{</html>}}
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
|
||||||
|
<p>Better still, if you include <code>numbered="true"</code>, each highlight is enumberated so you can reference it directly in the ensuing text.</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="html-annotated numbered"><code>
|
||||||
|
<div <span class='highlight'>role="dialog"</span> <span class='highlight'>aria-labelledby="dialog-heading"</span>>
|
||||||
|
<button <span class='highlight'>aria-label="close"</span>>x</button>
|
||||||
|
<h2 <span class='highlight'>id="dialog-heading"</span>>Confirmation</h2>
|
||||||
|
<p>Press <strong>Okay</strong> to confirm or <strong>Cancel</strong></p>
|
||||||
|
<button>Okay</button>
|
||||||
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
|
</code></div>
|
||||||
|
|
||||||
|
|
||||||
|
<p>You just include <code>numbered="true"</code> on the opening shortcode tag:</p>
|
||||||
|
|
||||||
|
<pre class=""><code data-codeblock-shortcode>
|
||||||
|
{{<html numbered="true">}}
|
||||||
|
<div ((role="dialog")) ((aria-labelledby="dialog-heading"))>
|
||||||
|
<button ((aria-label="close"))>x</button>
|
||||||
|
<h2 ((id="dialog-heading"))>Confirmation</h2>
|
||||||
|
<p>Press <strong>Okay</strong> to confirm or <strong>Cancel</strong></p>
|
||||||
|
<button>Okay</button>
|
||||||
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
|
{{</html>}}
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pattern-section">
|
<div class="pattern-section">
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,5 @@
|
||||||
{{ $html := .Inner | htmlEscape }}
|
{{ $html := .Inner | htmlEscape }}
|
||||||
{{ $html := replace $html "((" "<span class='highlight'>" }}
|
{{ $html := replace $html "((" "<span class='highlight'>" }}
|
||||||
{{ $html := replace $html "))" "</span>" }}
|
{{ $html := replace $html "))" "</span>" }}
|
||||||
<div class="html-annotated"><code>{{ $html | safeHTML }}</code></div>
|
{{ $numbered := .Get "numbered" }}
|
||||||
|
<div class="html-annotated {{ if and ($numbered) (ne $numbered "false") }}numbered{{ end }}"><code>{{ $html | safeHTML }}</code></div>
|
||||||
|
|
|
@ -65,8 +65,10 @@ figure p img {
|
||||||
[data-expands]:focus svg,
|
[data-expands]:focus svg,
|
||||||
.patterns a:focus .text,
|
.patterns a:focus .text,
|
||||||
[for="themer"] :focus + [aria-hidden] {
|
[for="themer"] :focus + [aria-hidden] {
|
||||||
outline: 3px solid #888;
|
outline: 4px solid #999;
|
||||||
outline-offset: 2px;
|
}
|
||||||
|
a {
|
||||||
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
/* fix for IE :( */
|
/* fix for IE :( */
|
||||||
|
|
||||||
|
@ -382,7 +384,7 @@ caption {
|
||||||
}
|
}
|
||||||
#menu-button:focus {
|
#menu-button:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
box-shadow: inset 0 0 0 0.25rem #888;
|
box-shadow: inset 0 0 0 0.25rem #999;
|
||||||
}
|
}
|
||||||
/* Tables of contents */
|
/* Tables of contents */
|
||||||
|
|
||||||
|
@ -522,37 +524,30 @@ pre[class*=language-] code * {
|
||||||
margin-top: -1rem;
|
margin-top: -1rem;
|
||||||
}
|
}
|
||||||
.html-annotated {
|
.html-annotated {
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
padding: 1.5rem;
|
padding: 1.5rem;
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
counter-reset: annotation;
|
counter-reset: annotation;
|
||||||
}
|
}
|
||||||
.highlight {
|
.highlight {
|
||||||
background: #ddd;
|
background: #ddd;
|
||||||
padding: 0.25rem 0.5rem;
|
padding: 0.0625rem 0.33rem;
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
}
|
}
|
||||||
.highlight::after {
|
.numbered .highlight::after {
|
||||||
counter-increment: annotation;
|
counter-increment: annotation;
|
||||||
content: counter(annotation);
|
content: counter(annotation);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 0.5rem;
|
font-size: 0.5rem;
|
||||||
background: #111;
|
background: #111;
|
||||||
color: #fefefe;
|
color: #fefefe;
|
||||||
display: inline-block;
|
border-radius: 1rem;
|
||||||
width: 0.75rem;
|
margin-left: 0.25rem;
|
||||||
height: 0.75rem;
|
padding: 0.125em 0.5em;
|
||||||
line-height: 0.75rem;
|
vertical-align: 0.33em;
|
||||||
text-align: center;
|
|
||||||
border-radius: 1rem;
|
|
||||||
vertical-align: middle;
|
|
||||||
margin-left: 0.25rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*main {
|
/*main {
|
||||||
display: block;
|
display: block;
|
||||||
counter-reset: fig;
|
counter-reset: fig;
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
|
|
||||||
/* Enable scrolling by keyboard of code samples */
|
/* Enable scrolling by keyboard of code samples */
|
||||||
(function () {
|
(function () {
|
||||||
var codeBlocks = document.querySelectorAll('pre');
|
var codeBlocks = document.querySelectorAll('pre, .html-annotated');
|
||||||
|
|
||||||
Array.prototype.forEach.call(codeBlocks, function (block) {
|
Array.prototype.forEach.call(codeBlocks, function (block) {
|
||||||
if (block.querySelector('code')) {
|
if (block.querySelector('code')) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user