diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-03-25 20:09:24 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-03-25 20:09:24 -0700 |
commit | 0ee54549af0d012e60a7a750ebc939799125850e (patch) | |
tree | 387215a691f842a30e8cdb5135cdafba6a96045a /src/Text | |
parent | 942b7b8f9cee34ec28a6d509f9f8d06273679fa4 (diff) | |
download | pandoc-0ee54549af0d012e60a7a750ebc939799125850e.tar.gz |
SelfContained: strip off fragment, query of relative URL
before treating as a filename. This fixes `--self-contained`
when used with CSS files that include web fonts using the
method described here:
http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/
Examples from reveal.js themes:
"../../lib/font/league_gothic-webfont.eot?#iefix"
"../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular"
Closes #739.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/SelfContained.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs index 780d2de33..f1118b974 100644 --- a/src/Text/Pandoc/SelfContained.hs +++ b/src/Text/Pandoc/SelfContained.hs @@ -104,11 +104,15 @@ getItem userdata f = if isAbsoluteURI f then openURL f else do - let mime = case takeExtension f of - ".gz" -> getMimeType $ dropExtension f + -- strip off trailing query or fragment part, if relative URL. + -- this is needed for things like cmunrm.eot?#iefix, + -- which is used to get old versions of IE to work with web fonts. + let f' = takeWhile (\c -> c /= '?' && c /= '#') f + let mime = case takeExtension f' of + ".gz" -> getMimeType $ dropExtension f' x -> getMimeType x - exists <- doesFileExist f - cont <- if exists then B.readFile f else readDataFile userdata f + exists <- doesFileExist f' + cont <- if exists then B.readFile f' else readDataFile userdata f' return (cont, mime) getRaw :: Maybe FilePath -> String -> String -> IO (ByteString, String) |