diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2018-10-31 00:06:05 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2018-10-31 00:06:05 +0300 |
commit | 6f6e4c0d844688ab88a5b73d566eb76a74a91963 (patch) | |
tree | 24655c4a2fd2f186f707c82758a1e7d9e554a727 /src/Text | |
parent | 4fe28e947a38bffdbb4eeccb16e62dc1824b9c74 (diff) | |
download | pandoc-6f6e4c0d844688ab88a5b73d566eb76a74a91963.tar.gz |
Generalize parseFromString to any streams with Char token
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index f6a9f530f..15c1c0b18 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -206,6 +206,7 @@ import Data.List (intercalate, isSuffixOf, transpose) import qualified Data.Map as M import Data.Maybe (mapMaybe, fromMaybe) import qualified Data.Set as Set +import Data.String import Data.Text (Text) import Text.HTML.TagSoup.Entity (lookupEntity) import Text.Pandoc.Asciify (toAsciiChar) @@ -458,15 +459,15 @@ stringAnyCase (x:xs) = do return (firstChar:rest) -- | Parse contents of 'str' using 'parser' and return result. -parseFromString :: Monad m - => ParserT [Char] st m a +parseFromString :: (Monad m, Stream s m Char, IsString s) + => ParserT s st m r -> String - -> ParserT [Char] st m a + -> ParserT s st m r parseFromString parser str = do oldPos <- getPosition setPosition $ initialPos "chunk" oldInput <- getInput - setInput str + setInput $ fromString str result <- parser spaces eof |