Skip to content

Element identifier used by SvgPathImage should not be hardcoded #384

@m000

Description

@m000

SvgPathImage.process() uses the hardcoded element id qr-path for the produced svg path:

https://github.com/lincolnloop/python-qrcode/blame/456b01d41f16e0cfb0f70c687848e276b78c3e8a/qrcode/image/svg.py#L149-L159

This is problematic in cases where the svg qrcodes are inlined in a single html document rather than saved as standalone files. Usually this will not break anything, but it may cause annoyances if the output is fed to a tool that attempts to validate the html that contains the qrcodes.

E.g. I am producing an html file with several qrcodes in it, which I then feed to weasyprint to convert to pdf. I get one warning for each subsequent qrcode:

[2024-10-28 21:21:20 WARNING weasyprint/css/targets.py:94] Anchor defined twice: 'qr-path'

I am not sure if there is a use-case for hardcoding an id there, or even for having an id at all. The path element looks easily selectable using a number of DOM selectors, so id="qr-path" can probably go?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions