Skip to content

markup/highlight: Allow overriding type and code via options#14925

Open
bep wants to merge 1 commit into
gohugoio:masterfrom
bep:fix/issue-11872
Open

markup/highlight: Allow overriding type and code via options#14925
bep wants to merge 1 commit into
gohugoio:masterfrom
bep:fix/issue-11872

Conversation

@bep
Copy link
Copy Markdown
Member

@bep bep commented May 21, 2026

Treat type and code as highlighting options in both transform.Highlight
and transform.HighlightCodeBlock. The type option overrides the language
and code overrides the code, so the two functions now share the same
options handling.

transform.Highlight's LANG argument is now optional:

transform.Highlight CODE [LANG] [OPTIONS]

Fixes #11872
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

@gemini-code-assist
Copy link
Copy Markdown

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Hugo’s syntax highlighting pipeline to treat type (language) and code as first-class highlighting options, aligning the behavior between transform.Highlight (template function) and transform.HighlightCodeBlock (render hook helper). It also makes LANG optional for transform.Highlight.

Changes:

  • Make transform.Highlight accept CODE [LANG] [OPTIONS], with type/code in OPTIONS overriding LANG/CODE.
  • Allow transform.HighlightCodeBlock option overrides to replace the language (type) and code (code) coming from the code block context.
  • Add integration tests and update documentation for the new option behavior and signature.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tpl/transform/transform.go Changes Highlight signature and argument parsing to support optional LANG and shared options handling.
tpl/transform/transform_integration_test.go Adds integration coverage for type/code overrides in transform.Highlight.
markup/highlight/highlight.go Routes type/code overrides through the highlighter for both Highlight and HighlightCodeBlock paths.
markup/highlight/highlight_integration_test.go Adds integration test verifying code block language override fallback behavior.
markup/highlight/config.go Refactors/extends option application to allow type and code to override lang and code inputs.
docs/content/en/functions/transform/HighlightCodeBlock.md Documents special type/code keys for HighlightCodeBlock options.
docs/content/en/functions/transform/Highlight.md Updates signature/docs to reflect optional LANG and type/code override semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tpl/transform/transform.go Outdated
@bep bep force-pushed the fix/issue-11872 branch from 7c9bff2 to d36ee47 Compare May 21, 2026 14:52
Treat type and code as highlighting options in both transform.Highlight
and transform.HighlightCodeBlock. The type option overrides the language
and code overrides the code, so the two functions now share the same
options handling.

transform.Highlight's LANG argument is now optional:

	transform.Highlight CODE [LANG] [OPTIONS]

Fixes gohugoio#11872
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to specify language for transform.HighlightCodeBlock

2 participants