summaryrefslogtreecommitdiff
path: root/Text/Pandoc
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-10-31 15:50:18 +0300
committerdefanor <defanor@uberspace.net>2017-10-31 15:50:18 +0300
commit097ac68877acfa6d35ec3987b80ee1ae8da4ff62 (patch)
tree761975e4e2c45a830db726b687b41bc82483108f /Text/Pandoc
parent964b28e363a4b1f93dd50cb330e2a6440048f4b4 (diff)
Update to pandoc 2
Diffstat (limited to 'Text/Pandoc')
-rw-r--r--Text/Pandoc/Readers/Gopher.hs12
-rw-r--r--Text/Pandoc/Readers/Plain.hs9
2 files changed, 12 insertions, 9 deletions
diff --git a/Text/Pandoc/Readers/Gopher.hs b/Text/Pandoc/Readers/Gopher.hs
index de346f5..7ece808 100644
--- a/Text/Pandoc/Readers/Gopher.hs
+++ b/Text/Pandoc/Readers/Gopher.hs
@@ -13,10 +13,11 @@ that, there are some adjustments.
module Text.Pandoc.Readers.Gopher ( readGopher ) where
import Text.Pandoc.Definition
-import Text.Pandoc.Error
import Text.Parsec
-import Text.Parsec.String
+import Text.Parsec.Text
import Text.Pandoc.Readers.Plain
+import Text.Pandoc.Class
+import qualified Data.Text as T
-- | UNASCII ::= ASCII - [Tab CR-LF NUL].
@@ -75,9 +76,10 @@ pDirEntries = concat <$> manyTill (choice [pInfo, pLink] <* pEOL) pLastLine
-- | Reads Gopher directory entries, falls back to plain text on
-- failure.
-readGopher :: String -> Either PandocError Pandoc
-readGopher s = Right . Pandoc mempty . pure . Plain $
+readGopher :: PandocMonad m => T.Text -> m Pandoc
+readGopher s = pure . Pandoc mempty . pure . Plain $
case parse pDirEntries "directory entry" s of
-- fallback to plain text
- Left _ -> concatMap (\l -> (lineToInlines l) ++ [LineBreak]) $ lines s
+ Left _ ->
+ concatMap (\l -> (lineToInlines $ T.unpack l) ++ [LineBreak]) $ T.lines s
Right r -> r
diff --git a/Text/Pandoc/Readers/Plain.hs b/Text/Pandoc/Readers/Plain.hs
index cb8fb9b..0f07feb 100644
--- a/Text/Pandoc/Readers/Plain.hs
+++ b/Text/Pandoc/Readers/Plain.hs
@@ -11,7 +11,8 @@ module Text.Pandoc.Readers.Plain ( readPlain
) where
import Text.Pandoc.Definition
-import Text.Pandoc.Error
+import Text.Pandoc.Class
+import qualified Data.Text as T
-- | Translates a text line into a list of 'Inline' elements suitable
@@ -24,6 +25,6 @@ lineToInlines s = let (cur, next) = break (== ' ') s
-- | Reads plain text, always succeeding and producing a single
-- 'Plain' block.
-readPlain :: String -> Either PandocError Pandoc
-readPlain = Right . Pandoc mempty . pure . Plain .
- concatMap (\l -> (lineToInlines l) ++ [LineBreak]) . lines
+readPlain :: PandocMonad m => T.Text -> m Pandoc
+readPlain = pure . Pandoc mempty . pure . Plain .
+ concatMap (\l -> (lineToInlines $ T.unpack l) ++ [LineBreak]) . T.lines