fix: enable GFM extension for markdown rendering in proxy mode#9465
Open
icebear0828 wants to merge 1 commit intoAlistGo:mainfrom
Open
fix: enable GFM extension for markdown rendering in proxy mode#9465icebear0828 wants to merge 1 commit intoAlistGo:mainfrom
icebear0828 wants to merge 1 commit intoAlistGo:mainfrom
Conversation
When `filter_readme_scripts` is enabled, markdown files served through the proxy are converted to HTML using goldmark. However, the default goldmark converter does not include GFM (GitHub Flavored Markdown) extensions, causing tables, strikethrough, and other GFM syntax to be rendered as plain text instead of proper HTML elements. This adds `extension.GFM` to the goldmark converter so that GFM tables, strikethrough, autolinks, and task lists are correctly converted to HTML.
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.
Summary
When
filter_readme_scriptsis enabled, markdown files served through the proxy (/p/and/d/) are converted to HTML viagoldmark.Convert(). However, the default goldmark converter does not include GFM extensions, so tables, strikethrough, autolinks, and task lists are rendered as plain text instead of proper HTML elements.For example, a GFM table:
gets wrapped in
<p>as plain text instead of generating<table>HTML.This PR adds
extension.GFMto the goldmark converter. No new dependencies are needed —goldmark/extensionis part of thegithub.com/yuin/goldmarkpackage already ingo.mod.Changes
server/handles/down.go: Replacegoldmark.Convert()with a goldmark instance configured withextension.GFMTest plan
filter_readme_scriptsin settings<table>element instead of plain text in<p>~~text~~) also renders correctly