git.iko.soy/typeable/pandoc
on master help sign in
RST Reader: Warn about skipped directives
87e536bDaniel Bergey
src/Text/Pandoc/Parsing.hs+8
@@ -162,6 +162,7 @@ module Text.Pandoc.Parsing ( anyLine,
162 setSourceColumn,
162 setSourceColumn,
163 setSourceLine,
163 setSourceLine,
164 newPos,
164 newPos,
165+ addWarning
165 )
166 )
166where
167where
167
168
@@ -1245,3 +1246,10 @@ applyMacros' target = do
1245 then do macros <- extractMacros <$> getState
1246 then do macros <- extractMacros <$> getState
1246 return $ applyMacros macros target
1247 return $ applyMacros macros target
1247 else return target
1248 else return target
1249+
1250+-- | Append a warning to the log.
1251+addWarning :: Maybe SourcePos -> String -> Parser [Char] ParserState ()
1252+addWarning mbpos msg =
1253+ updateState $ \st -> st{
1254+ stateWarnings = (msg ++ maybe "" (\pos -> " " ++ show pos) mbpos) :
1255+ stateWarnings st }
src/Text/Pandoc/Readers/Markdown.hs−6
@@ -343,12 +343,6 @@ parseMarkdown = do
343 let Pandoc _ bs = B.doc $ runF blocks st
343 let Pandoc _ bs = B.doc $ runF blocks st
344 return $ Pandoc meta bs
344 return $ Pandoc meta bs
345
345
346−addWarning :: Maybe SourcePos -> String -> MarkdownParser ()
347−addWarning mbpos msg =
348− updateState $ \st -> st{
349− stateWarnings = (msg ++ maybe "" (\pos -> " " ++ show pos) mbpos) :
350− stateWarnings st }
351−
352referenceKey :: MarkdownParser (F Blocks)
346referenceKey :: MarkdownParser (F Blocks)
353referenceKey = try $ do
347referenceKey = try $ do
354 pos <- getPosition
348 pos <- getPosition
src/Text/Pandoc/Readers/RST.hs+4−1
@@ -608,7 +608,10 @@ directive' = do
608 "" -> block
608 "" -> block
609 _ -> parseFromString parseBlocks body'
609 _ -> parseFromString parseBlocks body'
610 return $ B.divWith attrs children
610 return $ B.divWith attrs children
611+ other -> do
612+ pos <- getPosition
613+ addWarning (Just pos) $ "ignoring unknown directive: " ++ other
611− _ -> return mempty
614+ return mempty
612
615
613-- TODO:
616-- TODO:
614-- - Silently ignores illegal fields
617-- - Silently ignores illegal fields