git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: parse Text instead of String
8f84129Alexander Krotov
src/Text/Pandoc/Readers/Muse.hs+5−3
@@ -56,10 +56,11 @@ import Text.Pandoc.Builder (Blocks, Inlines)
56import qualified Text.Pandoc.Builder as B
56import qualified Text.Pandoc.Builder as B
57import Text.Pandoc.Class (PandocMonad (..))
57import Text.Pandoc.Class (PandocMonad (..))
58import Text.Pandoc.Definition
58import Text.Pandoc.Definition
59+import Text.Pandoc.Error (PandocError (PandocParsecError))
59import Text.Pandoc.Logging
60import Text.Pandoc.Logging
60import Text.Pandoc.Options
61import Text.Pandoc.Options
61import Text.Pandoc.Parsing hiding (F, enclosed)
62import Text.Pandoc.Parsing hiding (F, enclosed)
62−import Text.Pandoc.Shared (crFilter, underlineSpan)
63+import Text.Pandoc.Shared (crFilter, underlineSpan, mapLeft)
63
64
64-- | Read Muse from an input string and return a Pandoc document.
65-- | Read Muse from an input string and return a Pandoc document.
65readMuse :: PandocMonad m
66readMuse :: PandocMonad m
@@ -67,7 +68,8 @@ readMuse :: PandocMonad m
67 -> Text
68 -> Text
68 -> m Pandoc
69 -> m Pandoc
69readMuse opts s = do
70readMuse opts s = do
71+ let input = crFilter s
70− res <- readWithM parseMuse def{ museOptions = opts } (unpack (crFilter s))
72+ res <- mapLeft (PandocParsecError $ unpack input) `liftM` runParserT parseMuse def{ museOptions = opts } "source" input
71 case res of
73 case res of
72 Left e -> throwError e
74 Left e -> throwError e
73 Right d -> return d
75 Right d -> return d
@@ -97,7 +99,7 @@ instance Default MuseState where
97 , museInPara = False
99 , museInPara = False
98 }
100 }
99
101
100−type MuseParser = ParserT String MuseState
102+type MuseParser = ParserT Text MuseState
101
103
102instance HasReaderOptions MuseState where
104instance HasReaderOptions MuseState where
103 extractReaderOptions = museOptions
105 extractReaderOptions = museOptions