git.iko.soy/typeable/pandoc
on master help sign in
Class: rename addWarning[WithPos] to warning[WithPos].
a4bd650John MacFarlane
src/Text/Pandoc/Class.hs+10−12
@@ -36,8 +36,8 @@ module Text.Pandoc.Class ( PandocMonad(..)
36 , PureState(..)
36 , PureState(..)
37 , getPOSIXTime
37 , getPOSIXTime
38 , getZonedTime
38 , getZonedTime
39− , addWarning
39+ , warning
40− , addWarningWithPos
40+ , warningWithPos
41 , getWarnings
41 , getWarnings
42 , getMediaBag
42 , getMediaBag
43 , setMediaBag
43 , setMediaBag
@@ -121,8 +121,8 @@ class (Functor m, Applicative m, Monad m, MonadError PandocError m, MonadState C
121
121
122-- Functions defined for all PandocMonad instances
122-- Functions defined for all PandocMonad instances
123
123
124−addWarning :: PandocMonad m => String -> m ()
124+warning :: PandocMonad m => String -> m ()
125−addWarning msg = modify $ \st -> st{stWarnings = msg : stWarnings st}
125+warning msg = modify $ \st -> st{stWarnings = msg : stWarnings st}
126
126
127getWarnings :: PandocMonad m => m [String]
127getWarnings :: PandocMonad m => m [String]
128getWarnings = gets stWarnings
128getWarnings = gets stWarnings
@@ -152,14 +152,12 @@ getZonedTime = do
152 tz <- getCurrentTimeZone
152 tz <- getCurrentTimeZone
153 return $ utcToZonedTime tz t
153 return $ utcToZonedTime tz t
154
154
155−addWarningWithPos :: PandocMonad m
155+warningWithPos :: PandocMonad m
156− => Maybe SourcePos
156+ => Maybe SourcePos
157− -> String
157+ -> String
158− -> ParserT [Char] ParserState m ()
158+ -> ParserT [Char] ParserState m ()
159−addWarningWithPos mbpos msg =
159+warningWithPos mbpos msg =
160− lift $
161− addWarning $
162− msg ++ maybe "" (\pos -> " " ++ show pos) mbpos
160+ lift $ warning $ msg ++ maybe "" (\pos -> " " ++ show pos) mbpos
163
161
164--
162--
165
163
src/Text/Pandoc/Readers/Docx.hs+2−2
@@ -108,7 +108,7 @@ readDocx :: PandocMonad m
108readDocx opts bytes
108readDocx opts bytes
109 | Right archive <- toArchiveOrFail bytes
109 | Right archive <- toArchiveOrFail bytes
110 , Right (docx, parserWarnings) <- archiveToDocxWithWarnings archive = do
110 , Right (docx, parserWarnings) <- archiveToDocxWithWarnings archive = do
111− mapM_ P.addWarning parserWarnings
111+ mapM_ P.warning parserWarnings
112 (meta, blks) <- docxToOutput opts docx
112 (meta, blks) <- docxToOutput opts docx
113 return $ Pandoc meta blks
113 return $ Pandoc meta blks
114readDocx _ _ =
114readDocx _ _ =
@@ -334,7 +334,7 @@ blocksToInlinesWarn cmtId blks = do
334 notParaOrPlain (Plain _) = False
334 notParaOrPlain (Plain _) = False
335 notParaOrPlain _ = True
335 notParaOrPlain _ = True
336 when (not $ null $ filter notParaOrPlain blkList)
336 when (not $ null $ filter notParaOrPlain blkList)
337− ((lift . lift) $ P.addWarning $ "Docx comment " ++ cmtId ++ " will not retain formatting")
337+ ((lift . lift) $ P.warning $ "Docx comment " ++ cmtId ++ " will not retain formatting")
338 return $ fromList $ blocksToInlines blkList
338 return $ fromList $ blocksToInlines blkList
339
339
340parPartToInlines :: PandocMonad m => ParPart -> DocxContext m Inlines
340parPartToInlines :: PandocMonad m => ParPart -> DocxContext m Inlines
src/Text/Pandoc/Readers/Markdown.hs+5−5
@@ -280,7 +280,7 @@ yamlMetaBlock = try $ do
280 ) nullMeta hashmap
280 ) nullMeta hashmap
281 Right Yaml.Null -> return nullMeta
281 Right Yaml.Null -> return nullMeta
282 Right _ -> do
282 Right _ -> do
283− P.addWarningWithPos (Just pos) "YAML header is not an object"
283+ P.warningWithPos (Just pos) "YAML header is not an object"
284 return nullMeta
284 return nullMeta
285 Left err' -> do
285 Left err' -> do
286 case err' of
286 case err' of
@@ -291,13 +291,13 @@ yamlMetaBlock = try $ do
291 yamlLine = yline
291 yamlLine = yline
292 , yamlColumn = ycol
292 , yamlColumn = ycol
293 }}) ->
293 }}) ->
294− P.addWarningWithPos (Just $ setSourceLine
294+ P.warningWithPos (Just $ setSourceLine
295 (setSourceColumn pos
295 (setSourceColumn pos
296 (sourceColumn pos + ycol))
296 (sourceColumn pos + ycol))
297 (sourceLine pos + 1 + yline))
297 (sourceLine pos + 1 + yline))
298 $ "Could not parse YAML header: " ++
298 $ "Could not parse YAML header: " ++
299 problem
299 problem
300− _ -> P.addWarningWithPos (Just pos)
300+ _ -> P.warningWithPos (Just pos)
301 $ "Could not parse YAML header: " ++
301 $ "Could not parse YAML header: " ++
302 show err'
302 show err'
303 return nullMeta
303 return nullMeta
@@ -420,7 +420,7 @@ referenceKey = try $ do
420 let oldkeys = stateKeys st
420 let oldkeys = stateKeys st
421 let key = toKey raw
421 let key = toKey raw
422 case M.lookup key oldkeys of
422 case M.lookup key oldkeys of
423− Just _ -> P.addWarningWithPos (Just pos) $ "Duplicate link reference `" ++ raw ++ "'"
423+ Just _ -> P.warningWithPos (Just pos) $ "Duplicate link reference `" ++ raw ++ "'"
424 Nothing -> return ()
424 Nothing -> return ()
425 updateState $ \s -> s { stateKeys = M.insert key (target, attr') oldkeys }
425 updateState $ \s -> s { stateKeys = M.insert key (target, attr') oldkeys }
426 return $ return mempty
426 return $ return mempty
@@ -486,7 +486,7 @@ noteBlock = try $ do
486 let newnote = (ref, parsed)
486 let newnote = (ref, parsed)
487 oldnotes <- stateNotes' <$> getState
487 oldnotes <- stateNotes' <$> getState
488 case lookup ref oldnotes of
488 case lookup ref oldnotes of
489− Just _ -> P.addWarningWithPos (Just pos) $ "Duplicate note reference `" ++ ref ++ "'"
489+ Just _ -> P.warningWithPos (Just pos) $ "Duplicate note reference `" ++ ref ++ "'"
490 Nothing -> return ()
490 Nothing -> return ()
491 updateState $ \s -> s { stateNotes' = newnote : oldnotes }
491 updateState $ \s -> s { stateNotes' = newnote : oldnotes }
492 return mempty
492 return mempty
src/Text/Pandoc/Readers/RST.hs+7−7
@@ -626,7 +626,7 @@ directive' = do
626 return $ B.divWith attrs children
626 return $ B.divWith attrs children
627 other -> do
627 other -> do
628 pos <- getPosition
628 pos <- getPosition
629− P.addWarningWithPos (Just pos) $ "ignoring unknown directive: " ++ other
629+ P.warningWithPos (Just pos) $ "ignoring unknown directive: " ++ other
630 return mempty
630 return mempty
631
631
632-- TODO:
632-- TODO:
@@ -654,20 +654,20 @@ addNewRole roleString fields = do
654
654
655 -- warn about syntax we ignore
655 -- warn about syntax we ignore
656 flip mapM_ fields $ \(key, _) -> case key of
656 flip mapM_ fields $ \(key, _) -> case key of
657− "language" -> when (baseRole /= "code") $ lift $ P.addWarning $
657+ "language" -> when (baseRole /= "code") $ lift $ P.warning $
658 "ignoring :language: field because the parent of role :" ++
658 "ignoring :language: field because the parent of role :" ++
659 role ++ ": is :" ++ baseRole ++ ": not :code:"
659 role ++ ": is :" ++ baseRole ++ ": not :code:"
660− "format" -> when (baseRole /= "raw") $ lift $ P.addWarning $
660+ "format" -> when (baseRole /= "raw") $ lift $ P.warning $
661 "ignoring :format: field because the parent of role :" ++
661 "ignoring :format: field because the parent of role :" ++
662 role ++ ": is :" ++ baseRole ++ ": not :raw:"
662 role ++ ": is :" ++ baseRole ++ ": not :raw:"
663− _ -> lift $ P.addWarning $ "ignoring unknown field :" ++ key ++
663+ _ -> lift $ P.warning $ "ignoring unknown field :" ++ key ++
664 ": in definition of role :" ++ role ++ ": in"
664 ": in definition of role :" ++ role ++ ": in"
665 when (parentRole == "raw" && countKeys "format" > 1) $
665 when (parentRole == "raw" && countKeys "format" > 1) $
666− lift $ P.addWarning $
666+ lift $ P.warning $
667 "ignoring :format: fields after the first in the definition of role :"
667 "ignoring :format: fields after the first in the definition of role :"
668 ++ role ++": in"
668 ++ role ++": in"
669 when (parentRole == "code" && countKeys "language" > 1) $
669 when (parentRole == "code" && countKeys "language" > 1) $
670− lift $ P.addWarning $
670+ lift $ P.warning $
671 "ignoring :language: fields after the first in the definition of role :"
671 "ignoring :language: fields after the first in the definition of role :"
672 ++ role ++": in"
672 ++ role ++": in"
673
673
@@ -1065,7 +1065,7 @@ renderRole contents fmt role attr = case role of
1065 renderRole contents newFmt newRole newAttr
1065 renderRole contents newFmt newRole newAttr
1066 Nothing -> do
1066 Nothing -> do
1067 pos <- getPosition
1067 pos <- getPosition
1068− P.addWarningWithPos (Just pos) $ "ignoring unknown role :" ++ custom ++ ": in"
1068+ P.warningWithPos (Just pos) $ "ignoring unknown role :" ++ custom ++ ": in"
1069 return $ B.str contents -- Undefined role
1069 return $ B.str contents -- Undefined role
1070 where
1070 where
1071 titleRef ref = return $ B.str ref -- FIXME: Not a sensible behaviour
1071 titleRef ref = return $ B.str ref -- FIXME: Not a sensible behaviour
src/Text/Pandoc/Readers/TWiki.hs+1−1
@@ -58,7 +58,7 @@ readTWiki :: PandocMonad m
58 -> m Pandoc
58 -> m Pandoc
59readTWiki opts s = case readTWikiWithWarnings' opts s of
59readTWiki opts s = case readTWikiWithWarnings' opts s of
60 Right (doc, warns) -> do
60 Right (doc, warns) -> do
61− mapM_ P.addWarning warns
61+ mapM_ P.warning warns
62 return doc
62 return doc
63 Left e -> throwError e
63 Left e -> throwError e
64
64
src/Text/Pandoc/Writers/Docx.hs+1−1
@@ -1182,7 +1182,7 @@ inlineToOpenXML' opts (Image attr alt (src, title)) = do
1182 res <- (lift . lift) $ P.fetchItem' (writerMediaBag opts) (writerSourceURL opts) src
1182 res <- (lift . lift) $ P.fetchItem' (writerMediaBag opts) (writerSourceURL opts) src
1183 case res of
1183 case res of
1184 Left (_ :: E.SomeException) -> do
1184 Left (_ :: E.SomeException) -> do
1185− (lift . lift) $ P.addWarning ("Could not find image `" ++ src ++ "', skipping...")
1185+ (lift . lift) $ P.warning ("Could not find image `" ++ src ++ "', skipping...")
1186 -- emit alt text
1186 -- emit alt text
1187 inlinesToOpenXML opts alt
1187 inlinesToOpenXML opts alt
1188 Right (img, mt) -> do
1188 Right (img, mt) -> do
src/Text/Pandoc/Writers/EPUB.hs+2−2
@@ -398,7 +398,7 @@ pandocToEPUB opts doc@(Pandoc meta _) = do
398 let matchingGlob f = do
398 let matchingGlob f = do
399 xs <- lift $ P.glob f
399 xs <- lift $ P.glob f
400 when (null xs) $
400 when (null xs) $
401− lift $ P.addWarning $ f ++ " did not match any font files."
401+ lift $ P.warning $ f ++ " did not match any font files."
402 return xs
402 return xs
403 let mkFontEntry f = mkEntry (takeFileName f) `fmap` (lift $ P.readFileLazy f)
403 let mkFontEntry f = mkEntry (takeFileName f) `fmap` (lift $ P.readFileLazy f)
404 fontFiles <- concat <$> mapM matchingGlob (writerEpubFonts opts')
404 fontFiles <- concat <$> mapM matchingGlob (writerEpubFonts opts')
@@ -864,7 +864,7 @@ modifyMediaRef opts oldsrc = do
864 (new, mbEntry) <-
864 (new, mbEntry) <-
865 case res of
865 case res of
866 Left _ -> do
866 Left _ -> do
867− lift $ P.addWarning $ "Could not find media `" ++ oldsrc ++ "', skipping..."
867+ lift $ P.warning $ "Could not find media `" ++ oldsrc ++ "', skipping..."
868 return (oldsrc, Nothing)
868 return (oldsrc, Nothing)
869 Right (img,mbMime) -> do
869 Right (img,mbMime) -> do
870 let new = "media/file" ++ show (length media) ++
870 let new = "media/file" ++ show (length media) ++
src/Text/Pandoc/Writers/ICML.hs+2−2
@@ -537,13 +537,13 @@ imageICML opts style attr (src, _) = do
537 res <- lift $ P.fetchItem (writerSourceURL opts) src
537 res <- lift $ P.fetchItem (writerSourceURL opts) src
538 imgS <- case res of
538 imgS <- case res of
539 Left (_) -> do
539 Left (_) -> do
540− lift $ P.addWarning $ "Could not find image `" ++ src ++ "', skipping..."
540+ lift $ P.warning $ "Could not find image `" ++ src ++ "', skipping..."
541 return def
541 return def
542 Right (img, _) -> do
542 Right (img, _) -> do
543 case imageSize img of
543 case imageSize img of
544 Right size -> return size
544 Right size -> return size
545 Left msg -> do
545 Left msg -> do
546− lift $ P.addWarning $ "Could not determine image size in `" ++
546+ lift $ P.warning $ "Could not determine image size in `" ++
547 src ++ "': " ++ msg
547 src ++ "': " ++ msg
548 return def
548 return def
549 let (ow, oh) = sizeInPoints imgS
549 let (ow, oh) = sizeInPoints imgS
src/Text/Pandoc/Writers/Math.hs+2−2
@@ -20,7 +20,7 @@ texMathToInlines mt inp = do
20 case res of
20 case res of
21 Right (Just ils) -> return ils
21 Right (Just ils) -> return ils
22 Right (Nothing) -> do
22 Right (Nothing) -> do
23− addWarning $ "Could not render TeX math as unicode, rendering as raw TeX:\n" ++ inp
23+ warning $ "Could not render TeX math as unicode, rendering as raw TeX:\n" ++ inp
24 return [mkFallback mt inp]
24 return [mkFallback mt inp]
25 Left il -> return [il]
25 Left il -> return [il]
26
26
@@ -40,7 +40,7 @@ convertMath writer mt str = do
40 case writer dt <$> readTeX str of
40 case writer dt <$> readTeX str of
41 Right r -> return (Right r)
41 Right r -> return (Right r)
42 Left e -> do
42 Left e -> do
43− addWarning $ "Could not convert TeX math, rendering as raw TeX:\n" ++
43+ warning $ "Could not convert TeX math, rendering as raw TeX:\n" ++
44 str ++ "\n" ++ e
44 str ++ "\n" ++ e
45 return (Left $ mkFallback mt str)
45 return (Left $ mkFallback mt str)
46 where dt = case mt of
46 where dt = case mt of
src/Text/Pandoc/Writers/ODT.hs+2−2
@@ -147,13 +147,13 @@ transformPicMath opts (Image attr@(id', cls, _) lab (src,t)) = do
147 res <- lift $ P.fetchItem' (writerMediaBag opts) (writerSourceURL opts) src
147 res <- lift $ P.fetchItem' (writerMediaBag opts) (writerSourceURL opts) src
148 case res of
148 case res of
149 Left (_ :: E.SomeException) -> do
149 Left (_ :: E.SomeException) -> do
150− lift $ P.addWarning $ "Could not find image `" ++ src ++ "', skipping..."
150+ lift $ P.warning $ "Could not find image `" ++ src ++ "', skipping..."
151 return $ Emph lab
151 return $ Emph lab
152 Right (img, mbMimeType) -> do
152 Right (img, mbMimeType) -> do
153 (ptX, ptY) <- case imageSize img of
153 (ptX, ptY) <- case imageSize img of
154 Right s -> return $ sizeInPoints s
154 Right s -> return $ sizeInPoints s
155 Left msg -> do
155 Left msg -> do
156− lift $ P.addWarning $ "Could not determine image size in `" ++
156+ lift $ P.warning $ "Could not determine image size in `" ++
157 src ++ "': " ++ msg
157 src ++ "': " ++ msg
158 return (100, 100)
158 return (100, 100)
159 let dims =
159 let dims =
src/Text/Pandoc/Writers/RTF.hs+6−6
@@ -36,7 +36,7 @@ import Text.Pandoc.Writers.Shared
36import Text.Pandoc.Writers.Math
36import Text.Pandoc.Writers.Math
37import Text.Pandoc.Templates (renderTemplate')
37import Text.Pandoc.Templates (renderTemplate')
38import Text.Pandoc.Walk
38import Text.Pandoc.Walk
39−import Text.Pandoc.Class (addWarning)
39+import Text.Pandoc.Class (warning)
40import Data.List ( isSuffixOf, intercalate )
40import Data.List ( isSuffixOf, intercalate )
41import Data.Char ( ord, chr, isDigit )
41import Data.Char ( ord, chr, isDigit )
42import qualified Data.ByteString as B
42import qualified Data.ByteString as B
@@ -64,7 +64,7 @@ rtfEmbedImage opts x@(Image attr _ (src,_)) = do
64 _ -> throwError $ PandocSomeError "Unknown file type"
64 _ -> throwError $ PandocSomeError "Unknown file type"
65 sizeSpec <- case imageSize imgdata of
65 sizeSpec <- case imageSize imgdata of
66 Left msg -> do
66 Left msg -> do
67− addWarning $ "Could not determine image size in `" ++
67+ warning $ "Could not determine image size in `" ++
68 src ++ "': " ++ msg
68 src ++ "': " ++ msg
69 return ""
69 return ""
70 Right sz -> return $ "\\picw" ++ show xpx ++
70 Right sz -> return $ "\\picw" ++ show xpx ++
@@ -78,17 +78,17 @@ rtfEmbedImage opts x@(Image attr _ (src,_)) = do
78 concat bytes ++ "}"
78 concat bytes ++ "}"
79 if B.null imgdata
79 if B.null imgdata
80 then do
80 then do
81− addWarning $ "Image " ++ src ++ " contained no data, skipping."
81+ warning $ "Image " ++ src ++ " contained no data, skipping."
82 return x
82 return x
83 else return $ RawInline (Format "rtf") raw
83 else return $ RawInline (Format "rtf") raw
84 | otherwise -> do
84 | otherwise -> do
85− addWarning $ "Image " ++ src ++ " is not a jpeg or png, skipping."
85+ warning $ "Image " ++ src ++ " is not a jpeg or png, skipping."
86 return x
86 return x
87 Right (_, Nothing) -> do
87 Right (_, Nothing) -> do
88− addWarning $ "Could not determine image type for " ++ src ++ ", skipping."
88+ warning $ "Could not determine image type for " ++ src ++ ", skipping."
89 return x
89 return x
90 Left e -> do
90 Left e -> do
91− addWarning $ "Could not fetch image " ++ src ++ "\n" ++ show e
91+ warning $ "Could not fetch image " ++ src ++ "\n" ++ show e
92 return x
92 return x
93rtfEmbedImage _ x = return x
93rtfEmbedImage _ x = return x
94
94