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

Read image size of Inkscape SVGs #3580

Merged
merged 1 commit into from
Apr 16, 2017
Merged

Read image size of Inkscape SVGs #3580

merged 1 commit into from
Apr 16, 2017

Conversation

schrieveslaach
Copy link
Contributor

I want to resolve #3579

@jgm jgm merged commit 1c8683f into jgm:master Apr 16, 2017
@jgm
Copy link
Owner

jgm commented Apr 16, 2017

Looks good to me, thanks!

@schrieveslaach schrieveslaach deleted the inkscape-svgs branch April 18, 2017 14:29
@mb21
Copy link
Collaborator

mb21 commented Apr 19, 2017

Well, this new version might err on the other side, e.g. it gives a false positive on HTML documents that contain inline SVGs, like:

<html><svg>foo</svg></html>

The problem in the old code was that it relied on a space after <svg, where in your example there was a newline. So instead, I propose this version:

findSvgTag img = prfx `elem` ["<svg ", "<svg\n", "<svg\r"]
  where
    prfx = B.take 5 $ last $ B.groupBy openingTag $ B.drop 7 img
    -- B.groupBy openingTag matches first "<svg" or "<html" but not "<!--"
    openingTag x y = x == '<' && y /= '!'

Btw, we should probably add a test...

@schrieveslaach
Copy link
Contributor Author

@mb21, what happens when the XML contains a comment? Works this as well?

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg

I tested the old code with and without the lines in front of <svg. I did not change the svg tag (kept it as it was).

@mb21
Copy link
Collaborator

mb21 commented Apr 20, 2017 via email

@schrieveslaach
Copy link
Contributor Author

@mb21, I tested your code and I provided another pull request.

link2xt pushed a commit to link2xt/pandoc that referenced this pull request Apr 25, 2017
jgm pushed a commit that referenced this pull request May 20, 2017
The old code made some unwise assumptions about
how the svg file would look.

See #3580.
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.

Pandoc Does Not Recognize Image Size of Inkscape SVGs
3 participants