You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When including an svg image via a data url, any text inside the svg image is no longer rendered. Bisecting showed that this is related to
Commit 302f09d. Reverting that commit fixes the issue described here, but may cause other problems to resurface.
I include a more detailed description of this bug below, as well as detailed instructions on how to reproduce it. According to the commit
message, commit 302f09d changed some behaviour from using relative paths in svg images to using absolute paths. Apparently, those absolute paths do not work with svg images included via data urls. A possible solution may be to use absolute paths for external images, but return to using relative paths for images included via data urls.
Problem description
I have a simple svg plot generated by matplotlib that I want to include in an html file and render to pdf using weasyprint. For convenience, I want to include the svg image via a data url in order to only rely on a single, standalone html file. This worked well in weasyprint prior to commit 302f09d, but is broken in more recent versions. The offending commit, which I identified using git bisect, was the following one:
302f09d54a6ea30a9b56f8bacc22e236bde997c6 is the first bad commit
commit 302f09d54a6ea30a9b56f8bacc22e236bde997c6
Author: Guillaume Ayoub <[email protected]>
Date: Mon Jan 3 14:14:36 2022 +0100
Always use absolute paths to get hrefs in SVG
Also be more fault-tolerant when trying to render use tags.
Fix #1531.
weasyprint/svg/__init__.py | 8 ++++++--
weasyprint/svg/defs.py | 8 ++++----
weasyprint/svg/images.py | 4 +---
3 files changed, 11 insertions(+), 9 deletions(-)
Reproducing the bug
Inline images in html files are rather unwieldy and somewhat unpleasant to the human eye. I include a small script below that creates such an image using python3 and matplotlib. Running this script produces an html file on stdout which can be used to reproduce the bug.
Summary
When including an svg image via a data url, any text inside the svg image is no longer rendered. Bisecting showed that this is related to
Commit 302f09d. Reverting that commit fixes the issue described here, but may cause other problems to resurface.
I include a more detailed description of this bug below, as well as detailed instructions on how to reproduce it. According to the commit
message, commit 302f09d changed some behaviour from using relative paths in svg images to using absolute paths. Apparently, those absolute paths do not work with svg images included via data urls. A possible solution may be to use absolute paths for external images, but return to using relative paths for images included via data urls.
Problem description
I have a simple svg plot generated by matplotlib that I want to include in an html file and render to pdf using weasyprint. For convenience, I want to include the svg image via a data url in order to only rely on a single, standalone html file. This worked well in weasyprint prior to commit 302f09d, but is broken in more recent versions. The offending commit, which I identified using git bisect, was the following one:
Reproducing the bug
Inline images in html files are rather unwieldy and somewhat unpleasant to the human eye. I include a small script below that creates such an image using python3 and matplotlib. Running this script produces an html file on stdout which can be used to reproduce the bug.
The text was updated successfully, but these errors were encountered: