git.iko.soy/typeable/pandoc
on master help sign in
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.

commit0ee54549af0d012e60a7a750ebc939799125850e authorJohn MacFarlane <fiddlosopher@gmail.com> dateMon 25 Mar 2013, 20:09 (14 years ago) parent942b7b8
1 file changed+8−4
src/Text/Pandoc/SelfContained.hs+8−4
src/Text/Pandoc/SelfContained.hs+8−4
@@ -104,11 +104,15 @@ getItem userdata f =
104104 if isAbsoluteURI f
105105 then openURL f
106106 else do
107− let mime = case takeExtension f of
108− ".gz" -> getMimeType $ dropExtension f
107+ -- strip off trailing query or fragment part, if relative URL.
108+ -- this is needed for things like cmunrm.eot?#iefix,
109+ -- which is used to get old versions of IE to work with web fonts.
110+ let f' = takeWhile (\c -> c /= '?' && c /= '#') f
111+ let mime = case takeExtension f' of
112+ ".gz" -> getMimeType $ dropExtension f'
109113 x -> getMimeType x
110− exists <- doesFileExist f
111− cont <- if exists then B.readFile f else readDataFile userdata f
114+ exists <- doesFileExist f'
115+ cont <- if exists then B.readFile f' else readDataFile userdata f'
112116 return (cont, mime)
113117
114118getRaw :: Maybe FilePath -> String -> String -> IO (ByteString, String)