@@ -28,7 +28,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2828
2929Conversion of markdown-formatted plain text to 'Pandoc' document.
3030-}
31−module Text.Pandoc.Readers.Markdown ( readMarkdown ) where
31+module Text.Pandoc.Readers.Markdown ( readMarkdown,
32+ readMarkdownWithWarnings ) where
3233
3334import Data.List ( transpose, sortBy, findIndex, intercalate )
3435import qualified Data.Map as M
@@ -63,6 +64,18 @@ readMarkdown :: ReaderOptions -- ^ Reader options
6364readMarkdown opts s =
6465 (readWith parseMarkdown) def{ stateOptions = opts } (s ++ "\n\n")
6566
67+-- | Read markdown from an input string and return a pair of a Pandoc document
68+-- and a list of warnings.
69+readMarkdownWithWarnings :: ReaderOptions -- ^ Reader options
70+ -> String -- ^ String to parse (assuming @'\n'@ line endings)
71+ -> (Pandoc, [String])
72+readMarkdownWithWarnings opts s =
73+ (readWith parseMarkdownWithWarnings) def{ stateOptions = opts } (s ++ "\n\n")
74+ where parseMarkdownWithWarnings = do
75+ doc <- parseMarkdown
76+ warnings <- stateWarnings <$> getState
77+ return (doc, warnings)
78+
6679trimInlinesF :: F Inlines -> F Inlines
6780trimInlinesF = liftM trimInlines
6881