Repository navigation
Read clip-path from style and CSS rules, and quoted url() references - #544
Merged
Merged
Conversation
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.
get_clippath()only reads theclip-pathattribute, and only in the exact formurl(#id). So the clip is silently dropped when it comes from:styleattribute:style="clip-path: url(#clip)",.cls-2 { clip-path: url(#clip-path); }, as in Illustrator's CSS exports and in svgo-optimized matplotlib charts,url("#clip"),url('#clip'),url( #clip ), which is how browsers serialize the property.Gradient fills already accept all of these (
_GRADIENT_URL_RE).get_clippath()now applies the style rules to the node first, as thebaseline-shiftlookup does (clip-pathis not inherited, so only the node itself is read), and parses the value with_GRADIENT_URL_RE.clip-path="none"still clips nothing.Real files: PyMuPDF's
docs/images/icons/icon-svg.svg(Illustrator) gets its 1 clip path, and the matplotlib charts in rapidfuzz's documentation (docs/Usage/img/*.svg) get their 18 each; on main they get none, so the plot lines are not clipped to the axes.Added
test_clipping_path_reference(attribute, both quotes, spaces,style, CSS class) andtest_clipping_path_none; 5 of the 8 cases fail on main. Added a### Fixedentry inCHANGELOG.md(I used #545, as I expect #544 for the<image>PR; I'll fix it if needed).pytest(without the network-dependent sample downloads),ruff format --check,ruff checkandmypy src testspass.AI-assisted (Claude Code); I reviewed and tested the change