Skip to content

Commit

Permalink
Document how to enable AsciiDoc syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
jmooring committed Aug 25, 2024
1 parent c3350f4 commit 22991a4
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions content/en/getting-started/configuration-markup.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,51 @@ To mitigate security risks, entries in the extension array may not contain forwa
my-attribute-name = "my value"
{{< /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

Run `hugo --logLevel debug` to examine Hugo's call to the Asciidoctor executable:
Expand Down

0 comments on commit 22991a4

Please sign in to comment.