summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-03-25 20:09:24 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-03-25 20:09:24 -0700
commit0ee54549af0d012e60a7a750ebc939799125850e (patch)
tree387215a691f842a30e8cdb5135cdafba6a96045a /src/Text
parent942b7b8f9cee34ec28a6d509f9f8d06273679fa4 (diff)
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.hs12
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)