Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looking for <svg in SVGs might fail #56

Open
MagicRB opened this issue Dec 18, 2024 · 1 comment
Open

Looking for <svg in SVGs might fail #56

MagicRB opened this issue Dec 18, 2024 · 1 comment

Comments

@MagicRB
Copy link

MagicRB commented Dec 18, 2024

The file https://upload.wikimedia.org/wikipedia/commons/4/44/Bridge_pictogram.svg has <svg\n not <svg and so I end up with the following error:

         at /nix/store/kmkz4snxnr6h28ys5y0z2jcjywafip1j-source/topology/renderers/svg/default.nix:52:25:
           51|       then let
           52|         withoutPrefix = head (tail (splitString "<svg " (builtins.readFile file)));
             |                         ^
           53|         content = head (splitString "</svg>" withoutPrefix);

       error: list index 0 is out of bounds

easily fixable but thought I should report.

EDIT: that specific SVG doesn't work anyway, hmm

@oddlama
Copy link
Owner

oddlama commented Dec 19, 2024

Yeah the whole parsing-in-nix is not optimal. I should think of a better way to do all this for v2.0 anyway. For the time being I'd recommend running all svgs through some optimizers, they will ensure the format is compatible:

nix-shell -p nodePackages.svgo scour
scour --enable-viewboxing -i original.svg -o tmp.svg
svgo -i tmp.svg -o final.svg

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

No branches or pull requests

2 participants