🐛 Stop icon roles leaking SVG into toc labels and search#279
Merged
Conversation
7732ba1 to
30232c7
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #279 +/- ##
==========================================
- Coverage 90.42% 90.41% -0.02%
==========================================
Files 13 13
Lines 1149 1158 +9
==========================================
+ Hits 1039 1047 +8
- Misses 110 111 +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:
|
Octicon and material icon roles returned a `nodes.raw` HTML node whose `astext()` was the whole SVG markup, polluting `clean_astext` contexts (toctree labels, search index titles/terms) when an icon began a title. Introduce an inline `sd_icon` node that carries the SVG in an attribute and has no Text children, rendered via an HTML visitor (other builders skip it). Also migrate the article-info octicons, which restores their `sd-pr-2` spacing class onto the rendered `<svg>` element.
30232c7 to
af77fb6
Compare
19 tasks
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.
The octicon/material icon roles returned
nodes.raw(format="html"), whoseastext()is the entire<svg>markup — so an icon at the start of a section title poured SVG junk into every plain-text context derived viaclean_astext. The measurable damage: the search index for such a page contained ~200 garbage title-terms (svg,path,viewbox, plus every path-coordinate fragment like002l,0zm8, …).Changes
sd_iconinline node carrying the markup in itssvgattribute with no text children, soastext() == ""; the HTML visitor writes the SVG, non-HTML builders skip it. Octicon and material roles (and the_all-octicontable) migrated offnodes.raw. The fontawesome role keeps its own span-based node — it was never affected (already text-free); the two now share the design principle.article-infoicons migrated too, which fixes a latent bug: itssd-pr-2padding class sat on the raw wrapper and was silently dropped by the HTML writer — it now lands on the<svg>element as intended.toctreeentry titles (core Sphinx parses those as plain text) — the supported pattern is the icon in the target page's own H1.Verification
home, page, rocket; body/sidebar icon HTML is byte-identical (regenerated snippet fixtures are a pureraw→sd_iconswap).titlesdisplay field keeps the rendered HTML (upstream behaviour, predates this fix, harmless — icon shows in search results); the new test locks the cross-versiontitletermsfix and gates the Sphinx-9 plain-text-titles assertions accordingly.Closes #99
Closes #117