From 87e536b43805fc0a9f49c2fc8de9af88a241dc00 Mon Sep 17 00:00:00 2001 From: Daniel Bergey Date: Fri, 5 Dec 2014 21:03:09 +0000 Subject: RST Reader: Warn about skipped directives move `addWarning` to Parsing.hs, so it can be used by Markdown & RST readers. --- src/Text/Pandoc/Readers/Markdown.hs | 6 ------ src/Text/Pandoc/Readers/RST.hs | 5 ++++- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index b8487b4e6..b70193ad3 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -343,12 +343,6 @@ parseMarkdown = do let Pandoc _ bs = B.doc $ runF blocks st return $ Pandoc meta bs -addWarning :: Maybe SourcePos -> String -> MarkdownParser () -addWarning mbpos msg = - updateState $ \st -> st{ - stateWarnings = (msg ++ maybe "" (\pos -> " " ++ show pos) mbpos) : - stateWarnings st } - referenceKey :: MarkdownParser (F Blocks) referenceKey = try $ do pos <- getPosition diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 732956981..5c67629d6 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -608,7 +608,10 @@ directive' = do "" -> block _ -> parseFromString parseBlocks body' return $ B.divWith attrs children - _ -> return mempty + other -> do + pos <- getPosition + addWarning (Just pos) $ "ignoring unknown directive: " ++ other + return mempty -- TODO: -- - Silently ignores illegal fields -- cgit v1.2.3