diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-06-28 20:59:18 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-06-28 20:59:18 -0700 |
commit | 7bbb0073595ad7250317c3a348b70d3a3f948a99 (patch) | |
tree | 8a53e5efac72f21bbcba858e797d2fffa0431c19 /src | |
parent | fe625e053d078e03d824a1df746196b8a2c697b1 (diff) |
Minor fixes to previous commit.
* Instead of defining readmeFile in Text.Pandoc.Data (which we forgot
to export anyway), we simply add a record for "README" to the
`dataFiles` lookup table. This allows simplifying some of the code
for `readDefaultDataFile` in SHared.
* As a bonus, `pandoc --print-default-data-file README` now works.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Data.hsb | 5 | ||||
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 11 |
2 files changed, 4 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Data.hsb b/src/Text/Pandoc/Data.hsb index cd8836a0b..3a0bf8ac4 100644 --- a/src/Text/Pandoc/Data.hsb +++ b/src/Text/Pandoc/Data.hsb @@ -4,7 +4,4 @@ module Text.Pandoc.Data (dataFiles) where import qualified Data.ByteString as B dataFiles :: [(FilePath, B.ByteString)] -dataFiles = %blobs "data" - -readmeFile :: B.ByteString -readmeFile = %blob "README" +dataFiles = ("README", %blob "README") : %blobs "data"
\ No newline at end of file diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 2090e1734..7a4753327 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -132,7 +132,7 @@ import qualified Data.Text as T (toUpper, pack, unpack) import Data.ByteString.Lazy (toChunks) #ifdef EMBED_DATA_FILES -import Text.Pandoc.Data (dataFiles, readmeFile) +import Text.Pandoc.Data (dataFiles) #else import Paths_pandoc (getDataFileName) #endif @@ -743,12 +743,6 @@ inDirectory path action = E.bracket (const $ setCurrentDirectory path >> action) readDefaultDataFile :: FilePath -> IO BS.ByteString -readDefaultDataFile "README" = -#ifdef EMBED_DATA_FILES - return readmeFile -#else - getDataFileName "README" >>= checkExistence >>= BS.readFile -#endif readDefaultDataFile fname = #ifdef EMBED_DATA_FILES case lookup (makeCanonical fname) dataFiles of @@ -760,7 +754,8 @@ readDefaultDataFile fname = go (_:as) ".." = as go as x = x : as #else - getDataFileName ("data" </> fname) >>= checkExistence >>= BS.readFile + getDataFileName fname' >>= checkExistence >>= BS.readFile + where fname' = if fname == "README" then fname else "data" </> fname #endif checkExistence :: FilePath -> IO FilePath |