Skip to content

registry: route legacy text/* media types to their application/* renderer - #47

Merged
achille-roussel merged 1 commit into
mainfrom
fix-xml-rendering
Jul 7, 2026
Merged

registry: route legacy text/* media types to their application/* renderer#47
achille-roussel merged 1 commit into
mainfrom
fix-xml-rendering

Conversation

@achille-roussel

Copy link
Copy Markdown
Contributor

Problem

https://blog.firetiger.com/sitemap.xml renders as a flat, unstyled gray line instead of indented, syntax-highlighted XML.

The server labels it Content-Type: text/xml; charset=utf-8. The CLI trusts a server-supplied content-type and passes it straight to stripes.Func, which only had the XML renderer registered under application/xml. text/xml didn't match, so it fell through to the generic text/ → plain-text fallback.

Detect already special-cased text/xmlapplication/xml, but that path is bypassed when the server provides the type directly.

Fix

In Func, when a text/foo media type isn't registered but its application/foo counterpart is, route to that renderer. This mirrors the existing application/x- legacy-alias handling. text/xmlapplication/xml is the RFC 7303 §B.2 case that fixes the sitemap; genuinely unknown text/* types still fall back to Text.

Testing

  • Added TestFuncTextAlias regression test.
  • Full suite green (go test ./...).
  • Verified end-to-end against the live URL — now renders as properly indented, highlighted XML.

🤖 Generated with Claude Code

…erer

Servers frequently label XML as "text/xml" (RFC 7303 §B.2 makes it
equivalent to application/xml) — e.g. blog.firetiger.com/sitemap.xml is
served as "text/xml; charset=utf-8". A server-supplied content-type is
passed straight to Func, bypassing Detect's existing text/xml special
case, so the XML renderer (registered only under application/xml) was
never selected and the sitemap rendered as flat plain text.

Func now falls back from an unregistered text/foo to a registered
application/foo, mirroring the existing application/x- legacy-alias
handling. Genuinely unknown text/* types still fall back to Text.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@achille-roussel
achille-roussel merged commit d2ff209 into main Jul 7, 2026
1 check passed
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.

1 participant