git.iko.soy/typeable/pandoc
on master help sign in
Added ReaderOptions parameter to readNative.

This makes it similar to the other readers -- even though ReaderOptions is essentially ignored, the uniformity is nice.

commit2e7b0c7edaac9fbba52ac3cbc6380dbfb74805cf authorJohn MacFarlane <jgm@berkeley.edu> dateSat 10 Dec 2016, 16:52 (10 years ago) parent6643e40
6 files changed+10−8
src/Text/Pandoc.hs+1−1 src/Text/Pandoc/Readers/Native.hs+4−2 tests/Tests/Old.hs+1−1 tests/Tests/Readers/Docx.hs+1−1 tests/Tests/Readers/Odt.hs+1−1 tests/Tests/Writers/Docx.hs+2−2
src/Text/Pandoc.hs+1−1
@@ -238,7 +238,7 @@ data Reader m = StringReader (ReaderOptions -> String -> m Pandoc)
238238
239239-- | Association list of formats and readers.
240240readers :: PandocMonad m => [(String, Reader m)]
241−readers = [ ("native" , StringReader $ \_ s -> readNative s)
241+readers = [ ("native" , StringReader readNative)
242242 ,("json" , StringReader $ \o s ->
243243 case readJSON o s of
244244 Right doc -> return doc
src/Text/Pandoc/Readers/Native.hs+4−2
@@ -32,6 +32,7 @@ module Text.Pandoc.Readers.Native ( readNative ) where
3232
3333import Text.Pandoc.Definition
3434import Text.Pandoc.Shared (safeRead)
35+import Text.Pandoc.Options (ReaderOptions)
3536
3637import Control.Monad.Except (throwError)
3738import Text.Pandoc.Error
@@ -48,9 +49,10 @@ import Text.Pandoc.Class
4849-- > Pandoc nullMeta [Plain [Str "hi"]]
4950--
5051readNative :: PandocMonad m
51− => String -- ^ String to parse (assuming @'\n'@ line endings)
52+ => ReaderOptions
53+ -> String -- ^ String to parse (assuming @'\n'@ line endings)
5254 -> m Pandoc
53−readNative s =
55+readNative _ s =
5456 case maybe (Pandoc nullMeta <$> readBlocks s) Right (safeRead s) of
5557 Right doc -> return doc
5658 Left _ -> throwError $ PandocParseError "couldn't read native"
tests/Tests/Old.hs+1−1
@@ -196,7 +196,7 @@ lhsReaderTest format =
196196 testWithNormalize normalizer "lhs" ["-r", format, "-w", "native"]
197197 ("lhs-test" <.> format) norm
198198 where normalizer = purely $ \nat -> do
199− d <- readNative nat
199+ d <- readNative def nat
200200 writeNative def $ normalize d
201201 norm = if format == "markdown+lhs"
202202 then "lhs-test-markdown.native"
tests/Tests/Readers/Docx.hs+1−1
@@ -44,7 +44,7 @@ compareOutput opts docxFile nativeFile = do
4444 df <- B.readFile docxFile
4545 nf <- Prelude.readFile nativeFile
4646 p <- runIOorExplode $ readDocx opts df
47− df' <- runIOorExplode $ readNative nf
47+ df' <- runIOorExplode $ readNative def nf
4848 return $ (noNorm p, noNorm df')
4949
5050testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO Test
tests/Tests/Readers/Odt.hs+1−1
@@ -63,7 +63,7 @@ compareOdtToNative :: TestCreator
6363compareOdtToNative opts odtPath nativePath = do
6464 nativeFile <- Prelude.readFile nativePath
6565 odtFile <- B.readFile odtPath
66− native <- getNoNormVia id "native" <$> runIO (readNative nativeFile)
66+ native <- getNoNormVia id "native" <$> runIO (readNative def nativeFile)
6767 odt <- getNoNormVia id "odt" <$> runIO (readOdt opts odtFile)
6868 return (odt,native)
6969
tests/Tests/Writers/Docx.hs+2−2
@@ -21,9 +21,9 @@ compareOutput opts nativeFileIn nativeFileOut = do
2121 nf' <- Prelude.readFile nativeFileOut
2222 let wopts = fst opts
2323 df <- runIOorExplode $ do
24− d <- readNative nf
24+ d <- readNative def nf
2525 writeDocx wopts{writerUserDataDir = Just (".." </> "data")} d
26− df' <- runIOorExplode (readNative nf')
26+ df' <- runIOorExplode (readNative def nf')
2727 p <- runIOorExplode $ readDocx (snd opts) df
2828 return (p, df')
2929