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

[Windows] --syntax-definition thinks absolute file paths are protocols #4836

Closed
adamschoenemann opened this issue Aug 15, 2018 · 13 comments
Closed

Comments

@adamschoenemann
Copy link

If the --syntax-definition option is given an absolute windows file path, it will error with fatal error: unsupported protocol in URI. It seems to be thinking that there is a protocol specification in the path (presumably because of the colon). I could not find this error with a few other options (e.g. --output), which is strange. There is a repro here: https://github.com/adamschoenemann/pandoc-bug-repro

Pandoc version is 2.2.3.2

@jgm
Copy link
Owner

jgm commented Aug 15, 2018 via email

@mb21
Copy link
Collaborator

mb21 commented Aug 15, 2018

If this is an issue, I think it is actually in Skylighting, specifically: http://hackage.haskell.org/package/skylighting-core/docs/src/Skylighting.Parser.html#application

@jgm
Copy link
Owner

jgm commented Aug 15, 2018 via email

@adamschoenemann
Copy link
Author

Thanks for a taking a look at this. Re. %cd% I did this since substituting with an actual absolute path would likely throw an error regardless since you're unlikely to have checked out the repro repo at the exact same absolute path as I have. cmd should replace %cd% with your current working directory.

Anyway, @mb21 is most likely right about it being specific to Skylighting and therefore HXT. I'll see if I can get time to investigate more on the HXT side and open an issue there.

@jgm
Copy link
Owner

jgm commented Aug 15, 2018

I don't see anything we can do about this on our end. You could submit an issue to https://github.com/UweSchmidt/hxt.

The part of the code in question is Text.XML.HXT.Arrow.XmlState.URIHandling, which uses parseURIReference from Network.URI. As you can see, this is what is causing the problem:

Prelude Network.URI> parseURIReference "C:/foo/bar"
Just C:/foo/bar

We work around this problem in pandoc by using a special wrapper: see Text.Pandoc.Class:

-- | Specialized version of parseURIReference that disallows
-- single-letter schemes.  Reason:  these are usually windows absolute
-- paths.
parseURIReference' :: String -> Maybe URI
parseURIReference' s =
  case parseURIReference s of
       Just u
         | length (uriScheme u) > 2  -> Just u
         | null (uriScheme u)        -> Just u  -- protocol-relative
       _                             -> Nothing

HXT could do something similar to fix this problem.

@adamschoenemann
Copy link
Author

Great, I'll write an issue on HXT. Thanks!

@jgm
Copy link
Owner

jgm commented Aug 16, 2018 via email

@jgm
Copy link
Owner

jgm commented Nov 1, 2018

HXT may no longer be an active project. Perhaps the solution is to rewrite this code in skylighting using conduit-xml or xml-light.

@jgm
Copy link
Owner

jgm commented Nov 1, 2018

Or, simpler, just use readString instead of readDocument?

jgm added a commit to jgm/skylighting that referenced this issue Nov 1, 2018
Otherwise HXT will take it to be a URI.

See jgm/pandoc#4836.
@jgm
Copy link
Owner

jgm commented Nov 1, 2018

I think I found a simple fix in pandoc itself. Can you test? Not easy for me to test on Windows.

@jgm jgm closed this as completed in 65614a8 Nov 1, 2018
@econwang
Copy link

econwang commented Nov 13, 2018

does not work on windows, also does not work with http links

@jgm
Copy link
Owner

jgm commented Nov 14, 2018

@econwang can you give more information? You tested what version of pandoc, with what exact command, and what results?

@econwang
Copy link

@econwang can you give more information? You tested what version of pandoc, with what exact command, and what results?

pandoc --syntax-definition=F:\SLib\stata.xml -o test.html test.md
fatal error: unsupported protocol in URI "F:\SLib\stata.xml"
pandoc 2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants