From 7f36925c48e862b8dd7c6ae55987bceea0e83e54 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 4 Jan 2013 11:32:17 -0800 Subject: Markdown reader: Export readMarkdownWithWarnings. Note: This is not yet used, and the parser does not yet generate any warnings. --- src/Text/Pandoc/Readers/Markdown.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3