Repository navigation
SVG: accept clip-path="none" and any url(#id) clip path reference - #2143
Merged
Merged
Conversation
andersonhc
approved these changes
Nov 10, 2026
RavSinghChandan
force-pushed
the
svg-clip-path-none
branch
from
November 10, 2026 04:01
fa38695 to
036107d
Compare
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.
apply_clipping_path()reads theclip-pathvalue withre.search(r"url\((\#\w+)\)", ...), which has two problems:clip-path="none", the CSS initial value, which Inkscape writes, fails with anAssertionError.-or a.is cut at that character:url(#clip-1)looks up#clip, so it either fails with aKeyError, or, worse, silently clips with another clip path whose id isclip. A quoted reference,url("#clip1"), is not found either.The method now reads the reference with
_extract_gradient_id(), the helper that already parsesurl(#id)for gradient fills (it accepts quotes, spaces and any id character), and applies no clipping when the value is not aurl(#id)reference.Berlin_location_map.svg(Wikipedia, in svglib's test samples) usesclip-path="none"on 29 elements and fails on master with theAssertionError; it renders with this change and the separate nested<defs>fix.Added
test_svg_clip_path_none(attribute andstyle) andtest_svg_clip_path_reference(ids with-and., and a quoted reference, next to a decoy#clip); all 5 cases fail on master.pytest test/svg test/drawing, black, pylint and mypy pass