Skip to content

Extract Markdown rendering to dedicated package#1136

Merged
Soner (shyim) merged 2 commits into
mainfrom
claude/storefront-html-seo-standards-lx6aq1
Jun 29, 2026
Merged

Extract Markdown rendering to dedicated package#1136
Soner (shyim) merged 2 commits into
mainfrom
claude/storefront-html-seo-standards-lx6aq1

Conversation

@shyim

Copy link
Copy Markdown
Member

Summary

Refactors Markdown rendering logic into a dedicated internal/markdown package 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/markdown package with:

    • markdown.go: Configures a goldmark instance with GFM support, auto heading IDs, hard wraps, and XHTML output
    • heading_renderer.go: Custom renderer that converts Markdown headings (#, ##, etc.) to <span class="hN"> elements instead of <h1>-<h6> tags, following Shopware Storefront SEO guidelines
    • heading_renderer_test.go: Comprehensive tests verifying heading rendering behavior and other Markdown features
    • ToHTML() function: Public API for converting Markdown content to HTML
  • Removed GetConfiguredGoldMark() function from internal/extension/changelog.go and replaced with calls to markdown.ToHTML()

  • Updated consumers:

    • internal/extension/changelog.go: Uses new markdown.ToHTML() instead of local goldmark configuration
    • cmd/account/account_producer_extension_info_push.go: Uses new markdown.ToHTML() instead of local goldmark configuration

Implementation Details

The custom spanHeadingRenderer intercepts 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

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-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.42857% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.28%. Comparing base (123774a) to head (4393cdb).

Files with missing lines Patch % Lines
...md/account/account_producer_extension_info_push.go 0.00% 2 Missing ⚠️
internal/markdown/markdown.go 94.11% 1 Missing ⚠️
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     
Flag Coverage Δ
go-test 47.28% <91.42%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shyim Soner (shyim) merged commit 4fbf5af into main Jun 29, 2026
3 checks passed
@shyim Soner (shyim) deleted the claude/storefront-html-seo-standards-lx6aq1 branch June 29, 2026 06:43
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.

3 participants