Skip to content

SVG: read definitions in a <defs> nested in another <defs> - #2146

Merged
andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:svg-nested-defs
Nov 10, 2026
Merged

andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:svg-nested-defs

Conversation

@RavSinghChandan

Copy link
Copy Markdown

handle_defs() does not recurse into a <defs> inside another <defs>: it logs "Ignoring unsupported SVG tag: " and skips everything in it, so the elements that reference those definitions fail with a KeyError.

Berlin_location_map.svg (Wikipedia, in svglib's test samples) has its clipPath1 in <defs id="genericDefs"><defs id="defs1">..., and fails with KeyError: '#clipPath1'. A nested <defs> is valid SVG, and handle_defs() now reads it like the outer one.

Added test_nested_defs; it fails on master. pytest test/svg test/drawing, black, pylint and mypy pass

@andersonhc
andersonhc merged commit 3072b6c into py-pdf:master Nov 10, 2026
23 checks 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.

2 participants