git.iko.soy/typeable/pandoc
on master help sign in
Fixed repeated log messages in RST reader.

See #3447. To complete fixes on this issue, we need to do the same for the other readers. Note that the changes required are minimal -- add reportLogMessages to the end of the main parser, and replace report with logMessage. (except for trace)

commita3412354a401a3e691de31caeb013e704399602f authorJohn MacFarlane <jgm@berkeley.edu> dateFri 17 Feb 2017, 13:01 (10 years ago) parent38daf9d
1 file changed+14−13
src/Text/Pandoc/Readers/RST.hs+14−13
src/Text/Pandoc/Readers/RST.hs+14−13
@@ -50,7 +50,7 @@ import Data.Sequence (viewr, ViewR(..))
5050import Data.Char (toLower, isHexDigit, isSpace, toUpper)
5151import Data.Monoid ((<>))
5252import Control.Monad.Except (throwError)
53−import Text.Pandoc.Class (PandocMonad, report, readFileFromDirs)
53+import Text.Pandoc.Class (PandocMonad, readFileFromDirs)
5454
5555-- TODO:
5656-- [ ] .. parsed-literal
@@ -171,6 +171,7 @@ parseRST = do
171171 let (blocks', meta') = if standalone
172172 then titleTransform (blocks, meta)
173173 else (blocks, meta)
174+ reportLogMessages
174175 return $ Pandoc meta' blocks'
175176
176177--
@@ -436,7 +437,7 @@ include = try $ do
436437 contentLines <- case mbContents of
437438 Just s -> return $ lines s
438439 Nothing -> do
439− report $ CouldNotLoadIncludeFile f oldPos
440+ logMessage $ CouldNotLoadIncludeFile f oldPos
440441 return []
441442 let numLines = length contentLines
442443 let startLine' = case startLine of
@@ -700,7 +701,7 @@ directive' = do
700701 return $ B.divWith attrs children
701702 other -> do
702703 pos <- getPosition
703− report $ SkippedContent (".. " ++ other) pos
704+ logMessage $ SkippedContent (".. " ++ other) pos
704705 return mempty
705706
706707tableDirective :: PandocMonad m
@@ -742,17 +743,17 @@ addNewRole roleString fields = do
742743
743744 -- warn about syntax we ignore
744745 flip mapM_ fields $ \(key, _) -> case key of
745− "language" -> when (baseRole /= "code") $ report $
746+ "language" -> when (baseRole /= "code") $ logMessage $
746747 SkippedContent ":language: [because parent of role is not :code:]"
747748 pos
748− "format" -> when (baseRole /= "raw") $ report $
749+ "format" -> when (baseRole /= "raw") $ logMessage $
749750 SkippedContent ":format: [because parent of role is not :raw:]" pos
750− _ -> report $ SkippedContent (":" ++ key ++ ":") pos
751+ _ -> logMessage $ SkippedContent (":" ++ key ++ ":") pos
751752 when (parentRole == "raw" && countKeys "format" > 1) $
752− report $ SkippedContent ":format: [after first in definition of role]"
753+ logMessage $ SkippedContent ":format: [after first in definition of role]"
753754 pos
754755 when (parentRole == "code" && countKeys "language" > 1) $
755− report $ SkippedContent
756+ logMessage $ SkippedContent
756757 ":language: [after first in definition of role]" pos
757758
758759 updateState $ \s -> s {
@@ -1154,7 +1155,7 @@ renderRole contents fmt role attr = case role of
11541155 renderRole contents newFmt newRole newAttr
11551156 Nothing -> do
11561157 pos <- getPosition
1157− report $ SkippedContent (":" ++ custom ++ ":") pos
1158+ logMessage $ SkippedContent (":" ++ custom ++ ":") pos
11581159 return $ B.str contents -- Undefined role
11591160 where
11601161 titleRef ref = return $ B.str ref -- FIXME: Not a sensible behaviour
@@ -1266,7 +1267,7 @@ lookupKey oldkeys key = do
12661267 case M.lookup key keyTable of
12671268 Nothing -> do
12681269 let Key key' = key
1269− report $ ReferenceNotFound key' pos
1270+ logMessage $ ReferenceNotFound key' pos
12701271 return (("",""),nullAttr)
12711272 -- check for keys of the form link_, which need to be resolved:
12721273 Just ((u@(_:_),""),_) | last u == '_' -> do
@@ -1274,7 +1275,7 @@ lookupKey oldkeys key = do
12741275 let newkey = toKey rawkey
12751276 if newkey `elem` oldkeys
12761277 then do
1277− report $ CircularReference rawkey pos
1278+ logMessage $ CircularReference rawkey pos
12781279 return (("",""),nullAttr)
12791280 else lookupKey (key:oldkeys) newkey
12801281 Just val -> return val
@@ -1301,7 +1302,7 @@ subst = try $ do
13011302 case M.lookup key substTable of
13021303 Nothing -> do
13031304 pos <- getPosition
1304− report $ ReferenceNotFound (show key) pos
1305+ logMessage $ ReferenceNotFound (show key) pos
13051306 return mempty
13061307 Just target -> return target
13071308
@@ -1315,7 +1316,7 @@ note = try $ do
13151316 case lookup ref notes of
13161317 Nothing -> do
13171318 pos <- getPosition
1318− report $ ReferenceNotFound ref pos
1319+ logMessage $ ReferenceNotFound ref pos
13191320 return mempty
13201321 Just raw -> do
13211322 -- We temporarily empty the note list while parsing the note,