mirror of
https://github.com/gohugoio/hugo.git
synced 2026-09-03 12:12:37 +00:00
Document how to enable AsciiDoc syntax highlighting
This commit is contained in:
@@ -302,6 +302,51 @@ To mitigate security risks, entries in the extension array may not contain forwa
|
|||||||
my-attribute-name = "my value"
|
my-attribute-name = "my value"
|
||||||
{{< /code-toggle >}}
|
{{< /code-toggle >}}
|
||||||
|
|
||||||
|
### AsciiDoc syntax highlighting
|
||||||
|
|
||||||
|
Follow the steps below to enable syntax highlighting.
|
||||||
|
|
||||||
|
Step 1
|
||||||
|
: Set the `source-highlighter` attribute in your site configuration. For example:
|
||||||
|
|
||||||
|
{{< code-toggle file=hugo >}}
|
||||||
|
[markup.asciidocExt.attributes]
|
||||||
|
source-highlighter = 'rouge'
|
||||||
|
{{< /code-toggle >}}
|
||||||
|
|
||||||
|
Step 2
|
||||||
|
: Generate the highlighter CSS. For example:
|
||||||
|
|
||||||
|
```text
|
||||||
|
rougify style monokai.sublime > assets/css/syntax.css
|
||||||
|
```
|
||||||
|
|
||||||
|
Step 3
|
||||||
|
: In your base template add a link to the CSS file:
|
||||||
|
|
||||||
|
{{< code file=layouts/_default/baseof.html >}}
|
||||||
|
<head>
|
||||||
|
...
|
||||||
|
{{ with resources.Get "css/syntax.css" }}
|
||||||
|
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
|
||||||
|
{{ end }}
|
||||||
|
...
|
||||||
|
</head>
|
||||||
|
{{< /code >}}
|
||||||
|
|
||||||
|
Then add the code to be highlighted to your markup:
|
||||||
|
|
||||||
|
```text
|
||||||
|
[#hello,ruby]
|
||||||
|
----
|
||||||
|
require 'sinatra'
|
||||||
|
|
||||||
|
get '/hi' do
|
||||||
|
"Hello World!"
|
||||||
|
end
|
||||||
|
----
|
||||||
|
```
|
||||||
|
|
||||||
### AsciiDoc troubleshooting
|
### AsciiDoc troubleshooting
|
||||||
|
|
||||||
Run `hugo --logLevel debug` to examine Hugo's call to the Asciidoctor executable:
|
Run `hugo --logLevel debug` to examine Hugo's call to the Asciidoctor executable:
|
||||||
|
|||||||
Reference in New Issue
Block a user