diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2022-10-03 13:05:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-03 13:05:38 -0700 |
| commit | ad0532244adfbd0ca9596a27506ed6161e4bc225 (patch) | |
| tree | 70cdf0534234805fb650fa349745abea5814d65c /src/Text/Pandoc/Data | |
| parent | 2d565eda9ec6df702bc0381ccb60fc3cc9699318 (diff) | |
Separate out T.P.Data, T.P.Translations from T.P.Class. (#8348)
This makes T.P.Class more self-contained, and suitable for extraction
into a separate package if desired.
[API changes]
- T.P.Data is now an exported module, providing `readDataFile`,
`readDefaultDataFile` (both formerly provided by T.P.Class),
and also `getDataFileNames` (formerly unexported in
T.P.App.CommandLineOptions).
- T.P.Translations is now an exported module (along with
T.P.Translations.Types), providing `readTranslations`,
`getTranslations`, `setTranslations`, `translateTerm`,
`lookupTerm`, `readTranslations`, `Term(..)`, and `Translations`.
- T.P.Class: `readDataFile`, `readDefaultDataFile`, `setTranslations`,
and `translateTerm` are no longer exported.
`checkUserDataDir` is now exported.
- Text.Pandoc now exports Text.Pandoc.Data and `setTranslations`
and `translateTerm`.
Diffstat (limited to 'src/Text/Pandoc/Data')
| -rw-r--r-- | src/Text/Pandoc/Data/BakedIn.hs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Data/BakedIn.hs b/src/Text/Pandoc/Data/BakedIn.hs new file mode 100644 index 000000000..801a63181 --- /dev/null +++ b/src/Text/Pandoc/Data/BakedIn.hs @@ -0,0 +1,32 @@ +{-# LANGUAGE TemplateHaskell #-} +{- | +Module : Text.Pandoc.Data.BakedIn +Copyright : Copyright (C) 2013-2022 John MacFarlane +License : GNU GPL, version 2 or above + +Maintainer : John MacFarlane <jgm@berkeley@edu> +Stability : alpha +Portability : portable + +Provide contents data files as Haskell values. +-} +module Text.Pandoc.Data.BakedIn (dataFiles) where + +import qualified Data.ByteString as B +import Data.FileEmbed +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")) : + -- handle the hidden file separately, since embedDir doesn't + -- include it: + ("docx/_rels/.rels", $(embedFile "data/docx/_rels/.rels")) : + ("pptx/_rels/.rels", $(embedFile "data/pptx/_rels/.rels")) : + $(embedDir "data") |
