summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Data.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-26 17:22:00 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-26 17:22:00 +0200
commit10d91c147968d2e4d63b99b5b0342624827f416f (patch)
tree3a739ffa0b56d3fa6b5e1524820a79031a996e67 /src/Text/Pandoc/Data.hs
parent604c824d38f255dd44fec9bb69052002b5a59495 (diff)
Use file-embed instead of hsb2hs to embed data files.
I think template haskell is robust enough now across platforms that this will work. Motivation: file-embed gives us better dependency tracking: if a data file changes, ghc/stack/cabal know to recompile the Data module. This also removes hsb2hs as a build dependency.
Diffstat (limited to 'src/Text/Pandoc/Data.hs')
-rw-r--r--src/Text/Pandoc/Data.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Data.hs b/src/Text/Pandoc/Data.hs
new file mode 100644
index 000000000..df26f5412
--- /dev/null
+++ b/src/Text/Pandoc/Data.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Text.Pandoc.Data (dataFiles) where
+
+import Data.FileEmbed
+import qualified Data.ByteString as B
+import System.FilePath (splitDirectories)
+import qualified System.FilePath.Posix as Posix
+
+-- We ensure that the data files are stored using Posix
+-- path separators (/), even on Windows.
+dataFiles :: [(FilePath, B.ByteString)]
+dataFiles = map (\(fp, contents) ->
+ (Posix.joinPath (splitDirectories fp), contents)) dataFiles'
+
+dataFiles' :: [(FilePath, B.ByteString)]
+dataFiles' = ("MANUAL.txt", $(embedFile "MANUAL.txt")) : $(embedDir "data")