Code block
Description
A syntax-highlighted code sample with its language as a caption.
Highlighting is applied in the browser by highlight.js, using the
--jc-code-* colour tokens. The language caption is 14px so it can
be read at a glance on a laptop.
Usage
Minimal example
{% code_block code="foo" language="bar" %}
Qualified tag usage
{% ui__code_block code="foo" language="bar" %}
Parameters
| Name | Type | Requirement | Default | Choices | Description |
|---|---|---|---|---|---|
code
|
str
|
Required | — | — | The source code. |
language
|
str
|
Required | — | — | highlight.js language name, e.g. python. |
Select variant preset
Background colour
Viewport width
Zoom level
{% code_block code="foo" language="bar" %}
<figure class="code-block ">
<figcaption class="code-block__lang">bar</figcaption>
<pre class="code-block__pre"><code class="language-bar">foo</code></pre>
</figure>