```js
// Javascript code with syntax highlighting.
var fun = function lang(l) {
dateformat.i18n = require('./lang/' + l)
return true;
}
```
{% highlight markdown %}
```js
// Javascript code with syntax highlighting.
var fun = function lang(l) {
dateformat.i18n = require('./lang/' + l)
return true;
}
```
{% endhighlight %}
Syntax highlighting, line numbers, and HTML compression do not work together; **the combination of these features generates invalid HTML that renders incorrectly**. To learn more, see ["Code with line numbers"]({% link docs/ui-components/code/line-numbers.md %}).
---
## Code blocks with rendered examples
To demonstrate front end code, sometimes it's useful to show a rendered example of that code. After including the styles from your project that you'll need to show the rendering, you can use a `` with the `code-example` class, followed by the code block syntax. If you want to render your output with Markdown instead of HTML, use the `markdown="1"` attribute to tell Jekyll that the code you are rendering will be in Markdown format... This is about to get meta...
[Link button](https://just-the-docs.com){: .btn }
```markdown
[Link button](https://just-the-docs.com){: .btn }
```
{% highlight markdown %}
[Link button](https://just-the-docs.com){: .btn }
```markdown
[Link button](https://just-the-docs.com){: .btn }
```
{% endhighlight %}
---
## Mermaid diagram code blocks
{: .d-inline-block }
New (v0.4.0)
{: .label .label-green }
[Mermaid](https://mermaid-js.github.io/mermaid/) allows you to add diagrams and visualizations using Markdown code blocks. **It is disabled by default**. However, you can turn on support for mermaid by adding a `mermaid` key to your `_config.yml`.
The minimum configuration requires a `version` key (matching a version in [jsDelivr](https://cdn.jsdelivr.net/npm/mermaid/)):
```yaml
mermaid:
# Version of mermaid library
# Pick an available version from https://cdn.jsdelivr.net/npm/mermaid/
version: "9.1.3"
```
Additional configuration options are loaded through `_includes/mermaid_config.js`. By default, the contents of the file are the empty object:
```js
// _includes/mermaid_config.js
{}
```
This loads the default settings.
The contents of this object should follow [mermaid's configuration API](https://mermaid.js.org/config/configuration.html). For example, to override the theme, change `_includes/mermaid_config.js` to:
```js
// _includes/mermaid_config.js
{
theme: "forest"
}
```
Once mermaid is installed, it can be used in markdown files. The markdown for a simple flowchart example might look like the following:
{% highlight markdown %}
```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
{% endhighlight %}
which renders:
```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
*Note: for demonstration purposes, we've enabled mermaid on this site. It is still disabled by default, and users need to opt-in to use it.*
### Using a local mermaid library
To load a local version of mermaid, also use the `path` key to specify the location of the library; e.g.
```yaml
mermaid:
version: "10.1.0"
# for (v10+)
path: "/assets/js/mermaid.esm.min.mjs"
# for (
=10`, this file is imported directly as an ESM module (rather than as a plain `