git.iko.soy/typeable/pandoc
on master help sign in
Made `embed_data_files` flag work.
c2fe3aaJohn MacFarlane
src/Text/Pandoc/Shared.hs+11−3
@@ -1,4 +1,4 @@
1−{-# LANGUAGE DeriveDataTypeable, CPP #-}
1+{-# LANGUAGE DeriveDataTypeable, CPP, TemplateHaskell #-}
2{-
2{-
3Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
3Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
4
4
@@ -504,12 +504,20 @@ inDirectory path action = do
504 setCurrentDirectory oldDir
504 setCurrentDirectory oldDir
505 return result
505 return result
506
506
507+#ifdef EMBED_DATA_FILES
508+dataFiles :: [(FilePath, B.ByteString)]
509+dataFiles = $(embedDir "data")
510+#endif
511+
507readDefaultDataFile :: FilePath -> IO B.ByteString
512readDefaultDataFile :: FilePath -> IO B.ByteString
508readDefaultDataFile fname =
513readDefaultDataFile fname =
509#ifdef EMBED_DATA_FILES
514#ifdef EMBED_DATA_FILES
510− TODO
515+ case lookup fname dataFiles of
516+ Nothing -> ioError $ userError
517+ $ "Data file `" ++ fname ++ "' does not exist"
518+ Just contents -> return contents
511#else
519#else
512− getDataFileName fname >>= B.readFile
520+ getDataFileName ("data" </> fname) >>= B.readFile
513#endif
521#endif
514
522
515-- | Read file from specified user data directory or, if not found there, from
523-- | Read file from specified user data directory or, if not found there, from