Skip to content

[Repo Assist] Fix HtmlElement SVG serialisation: LinearGradient/RadialGradient emitted invalid tag (radient)#1108

Open
github-actions[bot] wants to merge 7 commits intomainfrom
repo-assist/fix-htmlmodel-svg-tagnames-4a98562ff07f4a79
Open

[Repo Assist] Fix HtmlElement SVG serialisation: LinearGradient/RadialGradient emitted invalid tag (radient)#1108
github-actions[bot] wants to merge 7 commits intomainfrom
repo-assist/fix-htmlmodel-svg-tagnames-4a98562ff07f4a79

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Fix a typo in HtmlElement.ToString() that caused LinearGradient and RadialGradient to emit the invalid SVG tag (radient) instead of the correct (linearGradient) and (radialGradient).

Root Cause

In HtmlModel.fs, the helper match expression delegates to a format helper by passing the tag name as a string literal. Both LinearGradient and RadialGradient cases were passing "radient" instead of "linearGradient" and "radialGradient" respectively:

// Before (wrong):
| LinearGradient(props, children) -> format "radient" props children level
| RadialGradient(props, children) -> format "radient" props children level

// After (correct):
| LinearGradient(props, children) -> format "linearGradient" props children level
| RadialGradient(props, children) -> format "radialGradient" props children level

This is a pure typo — both branches accidentally shared the string "radient" instead of the full SVG tag names.

Impact

Any code that builds an HtmlElement.LinearGradient or HtmlElement.RadialGradient tree and serialises it to a string (via ToString() or the Razor template pipeline) would produce (radient) elements, which are invalid SVG and would be silently ignored by browsers.

Changes

File Change
src/FSharp.Formatting.Common/HtmlModel.fs Fix tag name strings for LinearGradient and RadialGradient
RELEASE_NOTES.md Add [Unreleased] changelog entry

Test Status

  • dotnet build FSharp.Formatting.sln --configuration Release — succeeded (1 pre-existing FS0760 warning, unchanged)
  • dotnet test tests/FSharp.Markdown.Tests — 281/281 passed
  • dotnet fantomas src/FSharp.Formatting.Common/HtmlModel.fs --check — no formatting issues

Generated by Repo Assist

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@4957663821dbb3260348084fa2f1659701950fef

…emitted wrong tag name 'radient'

Both LinearGradient and RadialGradient cases in HtmlElement.ToString() were
passing the literal string "radient" to the format helper instead of
"linearGradient" and "radialGradient" respectively. This meant that any
SVG element using these types would render as the invalid tag <radient> in
generated HTML.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review March 25, 2026 15:57
@nojaf
Copy link
Copy Markdown
Collaborator

nojaf commented Mar 30, 2026

/repo-assist can you explain where this is happening? What would the user do to hit this codepath?

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Mar 30, 2026

✗ Repo Assist encountered failed at {run-ended}.

@dsyme
Copy link
Copy Markdown
Contributor

dsyme commented Apr 1, 2026

/repo-assist can you explain where this is happening? What would the user do to hit this codepath?

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 1, 2026

✓ Repo Assist completed successfully at {run-ended}.

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 1, 2026

🤖 This is an automated response from Repo Assist.

Great question! Here's a breakdown:

Where it happens

HtmlElement.ToString() in src/FSharp.Formatting.Common/HtmlModel.fs, in the big rec format match expression. Each DU case calls format "<tag-name>" props children level to emit the HTML/SVG tag string. Before the fix, both branches passed "radient" instead of the correct names.

How a user hits it

FSharp.Formatting.HtmlModel is a public API — it's the same DSL used internally to build all fsdocs HTML output. A user would hit this by:

  1. Referencing FSharp.Formatting.Common in their project
  2. Opening FSharp.Formatting.HtmlModel.Html
  3. Building an SVG element with a gradient fill, e.g.:
open FSharp.Formatting.HtmlModel.Html

let gradientDef =
    defs [] [
        linearGradient [ Id "grad1" ] [
            stop [ Style "stop-color:rgb(255,255,0);stop-opacity:1" ] []
            stop [ Style "stop-color:rgb(255,0,0);stop-opacity:1" ] []
        ]
    ]

let chart =
    svg [ Width "300"; Height "200" ] [
        gradientDef
        rect [ Fill "url(#grad1)"; Width "300"; Height "200" ] []
    ]

printfn "%s" (chart.ToString())
// Before fix: emits <radient ...> tags → invalid SVG, gradient silently ignored by browser
// After fix:  emits <linearGradient ...> tags → correct SVG

Usage in practice

Neither linearGradient nor radialGradient are used anywhere in fsdocs itself (I checked) — they're purely for external library consumers building SVGs programmatically. That explains why the bug went undetected. Anyone using this API to render gradient-filled SVG charts would see a broken SVG (browsers silently drop unknown <radient> elements, so the fill would just disappear).

Generated by 🌈 Repo Assist at {run-started}. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@1f672aef974f4246124860fc532f82fe8a93a57e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants