What would it take to support Asciidoc code fences

I’m in the process of migrating an asciidoc based site over to Hugo, and I’m looking into my syntax highlighting options. Currently it looks like hugo does not support the native asciidoc format for source code blocks.

[source,go]
----
// code
----

The hugo blocks work

{{< highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" >}}
// ... code
{{< / highlight >}}

However this would require a mass migration of the current content, plus retraining contributors to the site to use a syntax not native to asciidoc. I know that asciidoc support is currently provided externally through the asciidoc or asciidoctor utlities, so perhaps there isn’t much of an option, but I thought I would ask if there are any other possibilities before going through the process of converting all of my code blocks.

Thanks in advance

I think this feature would be easier to sell if you found a general way of doing this what could be useful to others, not just the Asciidoc crowd. I really, really hope we can get native Asciidoc support some day.

We have possibly some other related scenarios. From Jekyll/Kramdown they have a “callout” syntax (not sure about the term):

{: warning }
Some warning text

The above is purely CSS formatting. But that is not supported in Blackfriday (default in Hugo), so you would probably do replacement with:

{{% warn %}}
Some warning text
{{% /warn %}}

Or possibly

{{% note class="warn" %}}
Some warning text
{{% /note %}}

If we could define and implement some rule-based preprocessor that takes callouts/Asciidoc code fences… whatever and translates them into the shortcode syntax of choice, then that could work.

So, you keep the source files as-is, but we do the translation. And when Hugo gets native support for the same, just remove some config.

Yeah, some kind of pre-processor sounds like a good general solution. Should I open an issue on this?

1 Like