Skip to content

Make Markdown fenced code block work with more syntaxes#37154

Merged
wxiaoguang merged 2 commits intogo-gitea:mainfrom
wxiaoguang:fix-markdown-render
Apr 9, 2026
Merged

Make Markdown fenced code block work with more syntaxes#37154
wxiaoguang merged 2 commits intogo-gitea:mainfrom
wxiaoguang:fix-markdown-render

Conversation

@wxiaoguang
Copy link
Copy Markdown
Contributor

See the new comment and test cases

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 9, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 9, 2026
@silverwind silverwind requested a review from Copilot April 9, 2026 12:35
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 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.FencedCodeBlock nodes 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.

Comment thread modules/markup/markdown/transform_codeblock.go
Comment thread modules/markup/markdown/goldmark.go
Comment thread modules/markup/markdown/markdown_test.go
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 9, 2026
@lunny lunny added the type/enhancement An improvement of existing functionality label Apr 9, 2026
@lunny lunny added this to the 1.27.0 milestone Apr 9, 2026
@wxiaoguang wxiaoguang enabled auto-merge (squash) April 9, 2026 23:27
@wxiaoguang wxiaoguang merged commit 45c80bf into go-gitea:main Apr 9, 2026
26 checks passed
@wxiaoguang wxiaoguang deleted the fix-markdown-render branch April 10, 2026 01:14
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants