@@ -28,7 +28,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29Conversion of markdown-formatted plain text to 'Pandoc' document.
29Conversion of markdown-formatted plain text to 'Pandoc' document.
31−module Text.Pandoc.Readers.Markdown ( readMarkdown ) where
31+module Text.Pandoc.Readers.Markdown ( readMarkdown,
32+ readMarkdownWithWarnings ) where
33import Data.List ( transpose, sortBy, findIndex, intercalate )
34import Data.List ( transpose, sortBy, findIndex, intercalate )
34import qualified Data.Map as M
35import qualified Data.Map as M
@@ -63,6 +64,18 @@ readMarkdown :: ReaderOptions -- ^ Reader options
63readMarkdown opts s =
64readMarkdown opts s =
64 (readWith parseMarkdown) def{ stateOptions = opts } (s ++ "\n\n")
65 (readWith parseMarkdown) def{ stateOptions = opts } (s ++ "\n\n")
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
76+ warnings <- stateWarnings <$> getState
77+ return (doc, warnings)
66trimInlinesF :: F Inlines -> F Inlines
79trimInlinesF :: F Inlines -> F Inlines
67trimInlinesF = liftM trimInlines
80trimInlinesF = liftM trimInlines