Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

highlight: fix codefence syntax in Hugo >= 0.121.0 #749

Closed
ehbauer opened this issue Dec 12, 2023 · 7 comments
Closed

highlight: fix codefence syntax in Hugo >= 0.121.0 #749

ehbauer opened this issue Dec 12, 2023 · 7 comments
Assignees
Labels
bug Something isn't working hugo This is a topic related to Hugo itself but not the theme
Milestone

Comments

@ehbauer
Copy link

ehbauer commented Dec 12, 2023

With the latest version of the Relearn theme I ran into a strange problem that only happens in the Gitlab build of a Hugo project that uses the theme. The Gitlab setup is the easiest from the docs:

image: registry.gitlab.com/pages/hugo/hugo_extended:latest

variables:
  GIT_SUBMODULE_STRATEGY: recursive

pages:
  script:
    - hugo
  artifacts:
    paths:
      - public
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

In one template I have some code snippets that specify a starting line number

```yaml {linenos=inline,linenostart=50}
# FINAL BUILD
FROM ubuntu-nginx-php:3.0.2-fpm8.2 AS prod
...

When building this fails with an error

Error: error building site: "/builds/nyyoy3xx/0/xxx/content/dev/boilerplate/docker/_index.md:149:1": execute of template failed: template: _default/_markup/render-codeblock.html:1:4: executing "_default/_markup/render-codeblock.html" at <partial "shortcodes/highlight.html" (dict "page" .Page "attributes" .Attributes "content" .Inner "options" .Options "type" .Type)>: error calling partial: "/builds/nyyoy3xx/0/xxxx/themes/relearn/layouts/partials/shortcodes/highlight.html:83:15": execute of template failed: template: partials/shortcodes/highlight.html:83:15: executing "partials/shortcodes/highlight.html" at <highlight $content $type $params>: error calling highlight: invalid Highlight option: linenostart

I couldn't really understand what the problem was and had to remove the linenostart specification for this to work. It is still mentioned in the docs and I don't see a relevant change in the highligh shortcode partial that would create the issue.

@McShelby
Copy link
Owner

I can't reproduce this. Without further information, your Hugo version might be outdated. The theme requires 0.112.4 at least.

@McShelby McShelby added the needsfeedback Further information is needed label Dec 12, 2023
@McShelby
Copy link
Owner

Seems to be an issue with Hugo 0.121. Or some change I yet have to discover. It's also not working without the theme's shortcode implementation (stock Hugo).

@McShelby
Copy link
Owner

Strange. I'll need to investigate. The plain Hugo new example works.

@McShelby
Copy link
Owner

Until this is fixed you could stay with the 0.120.x releases.

@ehbauer
Copy link
Author

ehbauer commented Dec 13, 2023

Thank you, this works. I dug into the 0.121 release notes but didn't see anything that could be relevant. There are no recently closed bugs that seem to relate to this. There is an open bug since 2021 that says this could relate to the Chroma lexer or fallback lexer gohugoio/hugo#8824

@ehbauer
Copy link
Author

ehbauer commented Dec 13, 2023

Correction, it does not run into an error but it also does not render the script block in 0.121. The element does not exist in the output; not even hidden, in its place there is no HTML code created. So, this has to be something that has existed longer and only now creates the error.

@McShelby McShelby changed the title Gitlab build with code snippet and linenostart fails highlight: fix build for codefence syntax in Hugo >= 0.121.0 Dec 13, 2023
@McShelby McShelby changed the title highlight: fix build for codefence syntax in Hugo >= 0.121.0 highlight: fix codefence syntax in Hugo >= 0.121.0 Dec 13, 2023
@McShelby McShelby self-assigned this Dec 13, 2023
@McShelby McShelby added bug Something isn't working hugo This is a topic related to Hugo itself but not the theme and removed needsfeedback Further information is needed labels Dec 13, 2023
@McShelby McShelby added this to the 5.24.0 milestone Dec 13, 2023
@McShelby
Copy link
Owner

This is now fixed. Something must have changed internally in Hugo. I suspect it's the new Go version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hugo This is a topic related to Hugo itself but not the theme
Projects
None yet
Development

No branches or pull requests

2 participants