gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
73.62k stars 7.39k forks source link

[asciidoctor] Missing code highlighter stylesheet #10485

Open anlar opened 1 year ago

anlar commented 1 year ago

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.107.0-2221b5b30a285d01220a26a82305906ad3291880+extended linux/amd64 BuildDate=2022-11-24T13:59:45Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes.

Details

I'm using Hugo to process Asciidoc articles with Coderay highlighter, with the following config.toml:

# MAIN

baseURL = '/'
languageCode = 'en'
title = 'Blog title'
theme = 'mainroad'

# SECURITY

# required to access asciidoctor
[security.exec]
allow = ["^dart-sass-embedded$", "^go$", "^npx$", "^postcss$", "^asciidoctor$"]

# ASCIIDOCTOR

[markup.asciidocExt]
  extensions = ["asciidoctor-diagram"]
  workingFolderCurrent = true
  [markup.asciidocExt.attributes]
    source-highlighter = "coderay"

With this config Hugo correctly renders code blocks (so they are wrapped in <pre class="CodeRay highlight">). Problem is that CSS for CodeRay is not included in result pages automatically.

As a workaround I could either:

Not sure if it is expected behavior or bug. But if it is expected there should be a note in External Helper Asciidoctor documentation.

foo-dogsquared commented 1 year ago

I've also done similar workarounds to make Asciidoctor work with rouge highlighter. The stylesheet are linked in the header which Hugo removes by adding --no-header-or-footer in the resulting conversion command. Though this could be configured to behave differently, it is closer to an expected behavior rather than a bug. I agree that this should be documented somehwere.

hybras commented 11 months ago

This is indeed expected behavior. Your workarounds are correct.