2021-08-25 13:33:29 +02:00
+++
title = "Code highlighting"
2022-08-05 23:53:30 +02:00
weight = 4
2021-08-25 13:33:29 +02:00
+++
2020-06-01 14:59:45 +01:00
2021-09-11 15:46:14 +02:00
The Relearn theme uses [Hugo's built-in syntax highlighting ](https://gohugo.io/content-management/syntax-highlighting/ ) for code.
2020-06-01 14:59:45 +01:00
## Markdown syntax
Wrap the code block with three backticks and the name of the language. Highlight will try to auto detect the language if one is not provided.
<!-- markdownlint - disable MD046 -->
2021-07-26 01:05:46 +02:00
````plaintext
```json
[
{
"title": "apples",
"count": [12000, 20000],
"description": {"text": "...", "sensitive": false}
},
{
"title": "oranges",
"count": [17500, null],
"description": {"text": "...", "sensitive": false}
}
]
2020-06-01 14:59:45 +01:00
```
2021-07-26 01:05:46 +02:00
````
2020-06-01 14:59:45 +01:00
<!-- markdownlint - disable MD046 -->
Renders to:
```json
[
{
"title": "apples",
"count": [12000, 20000],
"description": {"text": "...", "sensitive": false}
},
{
"title": "oranges",
"count": [17500, null],
"description": {"text": "...", "sensitive": false}
}
]
```
## Supported languages
2021-08-23 23:46:53 +01:00
Hugo comes with a [remarkable list ](https://gohugo.io/content-management/syntax-highlighting/#list-of-chroma-highlighting-languages ) of supported languages.
2020-06-01 14:59:45 +01:00
2021-09-23 21:46:32 +02:00
## Recommended configuration
2020-06-01 14:59:45 +01:00
2021-07-26 01:05:46 +02:00
You can choose a color theme from the [list of supported themes ](https://xyproto.github.io/splash/docs/all.html ) and add it in your `config.toml`
2020-06-01 14:59:45 +01:00
2021-07-26 01:05:46 +02:00
````toml
[markup]
[markup.highlight]
2023-01-14 01:39:28 +01:00
# if `guessSyntax = true` , there will be no unstyled code even if no language
# was given BUT Mermaid and Math codefences will not work anymore! So this is a
# mandatory setting for your site if you want to use Mermaid or Math codefences
2022-02-11 00:59:40 +01:00
guessSyntax = false
# choose a color theme or create your own
style = "base16-snazzy"
2021-07-26 01:05:46 +02:00
````