git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Export readMarkdownWithWarnings.

Note: This is not yet used, and the parser does not yet generate any warnings.

commit7f36925c48e862b8dd7c6ae55987bceea0e83e54 authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 4 Jan 2013, 11:32 (14 years ago) parent024c1ad
1 file changed+14−1
src/Text/Pandoc/Readers/Markdown.hs+14−1
src/Text/Pandoc/Readers/Markdown.hs+14−1
@@ -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