summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-01-04 11:32:17 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-01-04 11:32:17 -0800
commit7f36925c48e862b8dd7c6ae55987bceea0e83e54 (patch)
treee8cef8cf5c739b6f034bb5cb951f5c4592682ca2 /src
parent024c1ad3c5b7745dc60ce0aa30f6900021043ba0 (diff)
Markdown reader: Export readMarkdownWithWarnings.
Note: This is not yet used, and the parser does not yet generate any warnings.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 98ee40827..b687faae7 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -28,7 +28,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conversion of markdown-formatted plain text to 'Pandoc' document.
-}
-module Text.Pandoc.Readers.Markdown ( readMarkdown ) where
+module Text.Pandoc.Readers.Markdown ( readMarkdown,
+ readMarkdownWithWarnings ) where
import Data.List ( transpose, sortBy, findIndex, intercalate )
import qualified Data.Map as M
@@ -63,6 +64,18 @@ readMarkdown :: ReaderOptions -- ^ Reader options
readMarkdown opts s =
(readWith parseMarkdown) def{ stateOptions = opts } (s ++ "\n\n")
+-- | Read markdown from an input string and return a pair of a Pandoc document
+-- and a list of warnings.
+readMarkdownWithWarnings :: ReaderOptions -- ^ Reader options
+ -> String -- ^ String to parse (assuming @'\n'@ line endings)
+ -> (Pandoc, [String])
+readMarkdownWithWarnings opts s =
+ (readWith parseMarkdownWithWarnings) def{ stateOptions = opts } (s ++ "\n\n")
+ where parseMarkdownWithWarnings = do
+ doc <- parseMarkdown
+ warnings <- stateWarnings <$> getState
+ return (doc, warnings)
+
trimInlinesF :: F Inlines -> F Inlines
trimInlinesF = liftM trimInlines