Extract Markdown rendering to dedicated package#1136
Merged
Conversation
The HTML generated from Markdown for extension descriptions, installation manuals and changelogs is pushed to the Shopware Store and embedded inside a store page that already owns its heading hierarchy (the <h1> is the product title). Emitting real <h1>-<h6> tags for this description chrome injects competing headings and harms the page's SEO structure. Override goldmark's heading renderer so headings become <span class="hN">, preserving the visual hierarchy via CSS classes without the heading semantics, in line with the Shopware Storefront SEO guidelines. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PBDtkYXJLVjKTy84hCo5RC
Move the goldmark configuration and the span-heading renderer out of the extension package into a dedicated internal/markdown package. The package exposes New() for the configured goldmark instance and a ToHTML() helper that both the changelog parser and the store info push now use, removing the duplicated buffer/convert boilerplate. No behavior change: store-pushed Markdown still renders headings as <span class="hN"> instead of <h1>-<h6>. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PBDtkYXJLVjKTy84hCo5RC
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1136 +/- ##
==========================================
+ Coverage 47.22% 47.28% +0.06%
==========================================
Files 228 230 +2
Lines 16497 16514 +17
==========================================
+ Hits 7791 7809 +18
+ Misses 8706 8705 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Refactors Markdown rendering logic into a dedicated
internal/markdownpackage to centralize configuration and enable consistent HTML generation across the CLI. This package is specifically configured for rendering Markdown content that will be embedded in Shopware Store pages, where headings must be rendered as styled spans rather than semantic heading tags to avoid conflicting with the store page's own heading hierarchy.Key Changes
New
internal/markdownpackage with:markdown.go: Configures a goldmark instance with GFM support, auto heading IDs, hard wraps, and XHTML outputheading_renderer.go: Custom renderer that converts Markdown headings (#,##, etc.) to<span class="hN">elements instead of<h1>-<h6>tags, following Shopware Storefront SEO guidelinesheading_renderer_test.go: Comprehensive tests verifying heading rendering behavior and other Markdown featuresToHTML()function: Public API for converting Markdown content to HTMLRemoved
GetConfiguredGoldMark()function frominternal/extension/changelog.goand replaced with calls tomarkdown.ToHTML()Updated consumers:
internal/extension/changelog.go: Uses newmarkdown.ToHTML()instead of local goldmark configurationcmd/account/account_producer_extension_info_push.go: Uses newmarkdown.ToHTML()instead of local goldmark configurationImplementation Details
The custom
spanHeadingRendererintercepts heading nodes during rendering and outputs<span class="hN">with appropriate CSS classes (h1-h6) instead of semantic heading elements. This preserves visual hierarchy while preventing SEO issues when the HTML is embedded in store pages that already have their own heading structure.https://claude.ai/code/session_01PBDtkYXJLVjKTy84hCo5RC