Make Markdown fenced code block work with more syntaxes#37154
Merged
wxiaoguang merged 2 commits intogo-gitea:mainfrom Apr 9, 2026
Merged
Make Markdown fenced code block work with more syntaxes#37154wxiaoguang merged 2 commits intogo-gitea:mainfrom
wxiaoguang merged 2 commits intogo-gitea:mainfrom
Conversation
TheFox0x7
approved these changes
Apr 9, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Markdown fenced code block language detection by normalizing the fenced “info string” so syntax highlighting works when the language is followed by common filename/option suffixes (eg js:app.ts, js,ignore, js ignore).
Changes:
- Add an AST transformer for
ast.FencedCodeBlocknodes that truncates the info string at the first separator (' ',',',':') so only the language remains. - Wire the new transformer into the existing Goldmark AST walk.
- Add unit tests covering several fenced code block info-string variants.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| modules/markup/markdown/transform_codeblock.go | Adds the fenced code block info-string normalization logic. |
| modules/markup/markdown/goldmark.go | Invokes the new transformation when walking the Goldmark AST. |
| modules/markup/markdown/markdown_test.go | Adds test cases validating syntax highlighting for extended fenced info syntaxes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lunny
approved these changes
Apr 9, 2026
zjjhot
added a commit
to zjjhot/gitea
that referenced
this pull request
Apr 10, 2026
* main: Make Markdown fenced code block work with more syntaxes (go-gitea#37154) Remove unneeded doctor sub-commands (go-gitea#37156) Report structurally invalid workflows to users (go-gitea#37116) Replace `rollup-plugin-license` with `rolldown-license-plugin` (go-gitea#37130) Clean up and improve non-gitea js error filter (go-gitea#37148)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See the new comment and test cases