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

commit7bbb0073595ad7250317c3a348b70d3a3f948a99 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 28 Jun 2015, 20:59 (11 years ago) parentfe625e0
2 files changed+4−12
src/Text/Pandoc/Data.hsb+1−4 src/Text/Pandoc/Shared.hs+3−8
src/Text/Pandoc/Data.hsb+1−4
@@ -4,7 +4,4 @@ module Text.Pandoc.Data (dataFiles) where
44import qualified Data.ByteString as B
55
66dataFiles :: [(FilePath, B.ByteString)]
7−dataFiles = %blobs "data"
8−
9−readmeFile :: B.ByteString
10−readmeFile = %blob "README"
7+dataFiles = ("README", %blob "README") : %blobs "data"
src/Text/Pandoc/Shared.hs+3−8
@@ -132,7 +132,7 @@ import qualified Data.Text as T (toUpper, pack, unpack)
132132import Data.ByteString.Lazy (toChunks)
133133
134134#ifdef EMBED_DATA_FILES
135−import Text.Pandoc.Data (dataFiles, readmeFile)
135+import Text.Pandoc.Data (dataFiles)
136136#else
137137import Paths_pandoc (getDataFileName)
138138#endif
@@ -743,12 +743,6 @@ inDirectory path action = E.bracket
743743 (const $ setCurrentDirectory path >> action)
744744
745745readDefaultDataFile :: FilePath -> IO BS.ByteString
746−readDefaultDataFile "README" =
747−#ifdef EMBED_DATA_FILES
748− return readmeFile
749−#else
750− getDataFileName "README" >>= checkExistence >>= BS.readFile
751−#endif
752746readDefaultDataFile fname =
753747#ifdef EMBED_DATA_FILES
754748 case lookup (makeCanonical fname) dataFiles of
@@ -760,7 +754,8 @@ readDefaultDataFile fname =
760754 go (_:as) ".." = as
761755 go as x = x : as
762756#else
763− getDataFileName ("data" </> fname) >>= checkExistence >>= BS.readFile
757+ getDataFileName fname' >>= checkExistence >>= BS.readFile
758+ where fname' = if fname == "README" then fname else "data" </> fname
764759#endif
765760
766761checkExistence :: FilePath -> IO FilePath