diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2015-02-18 13:05:15 +0000 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2015-02-18 21:09:06 +0000 |
commit | 4c910493458052e9a0a91a5ea948ab1b7457c9be (patch) | |
tree | 82d68ae87caa07fed913a7675094b59f5d063403 | |
parent | db6baab2171cd1866e3f4e46ecfedfe51a26ec06 (diff) | |
download | pandoc-4c910493458052e9a0a91a5ea948ab1b7457c9be.tar.gz |
Change return type of Org reader
-rw-r--r-- | src/Text/Pandoc/Readers/Org.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs index fd58956d0..9d2c355ee 100644 --- a/src/Text/Pandoc/Readers/Org.hs +++ b/src/Text/Pandoc/Readers/Org.hs @@ -58,19 +58,21 @@ import Data.Maybe (fromMaybe, isJust) import Data.Monoid (mconcat, mempty, mappend) import Network.HTTP (urlEncode) +import Text.Pandoc.Error + -- | Parse org-mode string and return a Pandoc document. readOrg :: ReaderOptions -- ^ Reader options -> String -- ^ String to parse (assuming @'\n'@ line endings) - -> Pandoc + -> Either PandocError Pandoc readOrg opts s = runOrg opts s parseOrg -runOrg :: ReaderOptions -> String -> OrgParser a -> a -runOrg opts inp p = fst res +runOrg :: ReaderOptions -> String -> OrgParser a -> Either PandocError a +runOrg opts inp p = fst <$> res where imd = readWithM (returnState p) def{ orgStateOptions = opts } (inp ++ "\n\n") res = runReader imd s s :: OrgParserState - s = snd $ runReader imd s + s = either def snd res type OrgParser a = ParserT [Char] OrgParserState (Reader OrgParserState) a |