aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-09-19 16:34:14 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-09-19 16:36:29 +0300
commit8f841297df2aa4dcb1789843e562d4404baf1bf0 (patch)
tree9f9ac417b83d48bbbd40dd1745f9c27e9dbb0db8 /src
parent841784fb57b05a404646a608447ba5ac903a3a31 (diff)
downloadpandoc-8f841297df2aa4dcb1789843e562d4404baf1bf0.tar.gz
Muse reader: parse Text instead of String
Benchmark shows 7% improvement
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index a1f0e19ac..a0069827a 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -56,10 +56,11 @@ import Text.Pandoc.Builder (Blocks, Inlines)
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Class (PandocMonad (..))
import Text.Pandoc.Definition
+import Text.Pandoc.Error (PandocError (PandocParsecError))
import Text.Pandoc.Logging
import Text.Pandoc.Options
import Text.Pandoc.Parsing hiding (F, enclosed)
-import Text.Pandoc.Shared (crFilter, underlineSpan)
+import Text.Pandoc.Shared (crFilter, underlineSpan, mapLeft)
-- | Read Muse from an input string and return a Pandoc document.
readMuse :: PandocMonad m
@@ -67,7 +68,8 @@ readMuse :: PandocMonad m
-> Text
-> m Pandoc
readMuse opts s = do
- res <- readWithM parseMuse def{ museOptions = opts } (unpack (crFilter s))
+ let input = crFilter s
+ res <- mapLeft (PandocParsecError $ unpack input) `liftM` runParserT parseMuse def{ museOptions = opts } "source" input
case res of
Left e -> throwError e
Right d -> return d
@@ -97,7 +99,7 @@ instance Default MuseState where
, museInPara = False
}
-type MuseParser = ParserT String MuseState
+type MuseParser = ParserT Text MuseState
instance HasReaderOptions MuseState where
extractReaderOptions = museOptions