git.iko.soy/typeable/pandoc
on master help sign in
Added ReaderOptions parameter to readNative.
2e7b0c7John MacFarlane
src/Text/Pandoc.hs+1−1
@@ -238,7 +238,7 @@ data Reader m = StringReader (ReaderOptions -> String -> m Pandoc)
238
238
239-- | Association list of formats and readers.
239-- | Association list of formats and readers.
240readers :: PandocMonad m => [(String, Reader m)]
240readers :: PandocMonad m => [(String, Reader m)]
241−readers = [ ("native" , StringReader $ \_ s -> readNative s)
241+readers = [ ("native" , StringReader readNative)
242 ,("json" , StringReader $ \o s ->
242 ,("json" , StringReader $ \o s ->
243 case readJSON o s of
243 case readJSON o s of
244 Right doc -> return doc
244 Right doc -> return doc
src/Text/Pandoc/Readers/Native.hs+4−2
@@ -32,6 +32,7 @@ module Text.Pandoc.Readers.Native ( readNative ) where
32
32
33import Text.Pandoc.Definition
33import Text.Pandoc.Definition
34import Text.Pandoc.Shared (safeRead)
34import Text.Pandoc.Shared (safeRead)
35+import Text.Pandoc.Options (ReaderOptions)
35
36
36import Control.Monad.Except (throwError)
37import Control.Monad.Except (throwError)
37import Text.Pandoc.Error
38import Text.Pandoc.Error
@@ -48,9 +49,10 @@ import Text.Pandoc.Class
48-- > Pandoc nullMeta [Plain [Str "hi"]]
49-- > Pandoc nullMeta [Plain [Str "hi"]]
49--
50--
50readNative :: PandocMonad m
51readNative :: PandocMonad m
52+ => ReaderOptions
51− => String -- ^ String to parse (assuming @'\n'@ line endings)
53+ -> String -- ^ String to parse (assuming @'\n'@ line endings)
52 -> m Pandoc
54 -> m Pandoc
53−readNative s =
55+readNative _ s =
54 case maybe (Pandoc nullMeta <$> readBlocks s) Right (safeRead s) of
56 case maybe (Pandoc nullMeta <$> readBlocks s) Right (safeRead s) of
55 Right doc -> return doc
57 Right doc -> return doc
56 Left _ -> throwError $ PandocParseError "couldn't read native"
58 Left _ -> throwError $ PandocParseError "couldn't read native"
tests/Tests/Old.hs+1−1
@@ -196,7 +196,7 @@ lhsReaderTest format =
196 testWithNormalize normalizer "lhs" ["-r", format, "-w", "native"]
196 testWithNormalize normalizer "lhs" ["-r", format, "-w", "native"]
197 ("lhs-test" <.> format) norm
197 ("lhs-test" <.> format) norm
198 where normalizer = purely $ \nat -> do
198 where normalizer = purely $ \nat -> do
199− d <- readNative nat
199+ d <- readNative def nat
200 writeNative def $ normalize d
200 writeNative def $ normalize d
201 norm = if format == "markdown+lhs"
201 norm = if format == "markdown+lhs"
202 then "lhs-test-markdown.native"
202 then "lhs-test-markdown.native"
tests/Tests/Readers/Docx.hs+1−1
@@ -44,7 +44,7 @@ compareOutput opts docxFile nativeFile = do
44 df <- B.readFile docxFile
44 df <- B.readFile docxFile
45 nf <- Prelude.readFile nativeFile
45 nf <- Prelude.readFile nativeFile
46 p <- runIOorExplode $ readDocx opts df
46 p <- runIOorExplode $ readDocx opts df
47− df' <- runIOorExplode $ readNative nf
47+ df' <- runIOorExplode $ readNative def nf
48 return $ (noNorm p, noNorm df')
48 return $ (noNorm p, noNorm df')
49
49
50testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO Test
50testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO Test
tests/Tests/Readers/Odt.hs+1−1
@@ -63,7 +63,7 @@ compareOdtToNative :: TestCreator
63compareOdtToNative opts odtPath nativePath = do
63compareOdtToNative opts odtPath nativePath = do
64 nativeFile <- Prelude.readFile nativePath
64 nativeFile <- Prelude.readFile nativePath
65 odtFile <- B.readFile odtPath
65 odtFile <- B.readFile odtPath
66− native <- getNoNormVia id "native" <$> runIO (readNative nativeFile)
66+ native <- getNoNormVia id "native" <$> runIO (readNative def nativeFile)
67 odt <- getNoNormVia id "odt" <$> runIO (readOdt opts odtFile)
67 odt <- getNoNormVia id "odt" <$> runIO (readOdt opts odtFile)
68 return (odt,native)
68 return (odt,native)
69
69
tests/Tests/Writers/Docx.hs+2−2
@@ -21,9 +21,9 @@ compareOutput opts nativeFileIn nativeFileOut = do
21 nf' <- Prelude.readFile nativeFileOut
21 nf' <- Prelude.readFile nativeFileOut
22 let wopts = fst opts
22 let wopts = fst opts
23 df <- runIOorExplode $ do
23 df <- runIOorExplode $ do
24− d <- readNative nf
24+ d <- readNative def nf
25 writeDocx wopts{writerUserDataDir = Just (".." </> "data")} d
25 writeDocx wopts{writerUserDataDir = Just (".." </> "data")} d
26− df' <- runIOorExplode (readNative nf')
26+ df' <- runIOorExplode (readNative def nf')
27 p <- runIOorExplode $ readDocx (snd opts) df
27 p <- runIOorExplode $ readDocx (snd opts) df
28 return (p, df')
28 return (p, df')
29
29