git.iko.soy/typeable/pandoc
on master help sign in
Have warningWithPos take a SourcePos rather than Maybe SourcePos.
e1d2da4John MacFarlane
src/Text/Pandoc/Class.hs+22−12
@@ -72,7 +72,7 @@ import qualified Text.Pandoc.Shared as IO ( fetchItem
72 , readDataFile
72 , readDataFile
73 , warn)
73 , warn)
74import Text.Pandoc.Compat.Time (UTCTime)
74import Text.Pandoc.Compat.Time (UTCTime)
75−import Text.Pandoc.Parsing (ParserT, ParserState, SourcePos)
75+import Text.Pandoc.Parsing (ParserT, SourcePos)
76import qualified Text.Pandoc.Compat.Time as IO (getCurrentTime)
76import qualified Text.Pandoc.Compat.Time as IO (getCurrentTime)
77import Data.Time.Clock.POSIX ( utcTimeToPOSIXSeconds
77import Data.Time.Clock.POSIX ( utcTimeToPOSIXSeconds
78 , posixSecondsToUTCTime
78 , posixSecondsToUTCTime
@@ -121,7 +121,7 @@ class (Functor m, Applicative m, Monad m, MonadError PandocError m, MonadState C
121 glob :: String -> m [FilePath]
121 glob :: String -> m [FilePath]
122 getModificationTime :: FilePath -> m UTCTime
122 getModificationTime :: FilePath -> m UTCTime
123
123
124−
124+
125
125
126-- Functions defined for all PandocMonad instances
126-- Functions defined for all PandocMonad instances
127
127
@@ -157,11 +157,10 @@ getZonedTime = do
157 return $ utcToZonedTime tz t
157 return $ utcToZonedTime tz t
158
158
159warningWithPos :: PandocMonad m
159warningWithPos :: PandocMonad m
160− => Maybe SourcePos
160+ => SourcePos
161 -> String
161 -> String
162− -> ParserT [Char] ParserState m ()
162+ -> ParserT s st m ()
163−warningWithPos mbpos msg =
164− lift $ warning $ msg ++ maybe "" (\pos -> " " ++ show pos) mbpos
163+warningWithPos pos msg = lift $ warning $ msg ++ " " ++ show pos
165
164
166--
165--
167
166
@@ -377,9 +376,20 @@ instance PandocMonad PandocPure where
377 Just tm -> return tm
376 Just tm -> return tm
378 Nothing -> throwError $ PandocFileReadError fp
377 Nothing -> throwError $ PandocFileReadError fp
379
378
380−
379+{-
381−
380+instance PandocMonad m => PandocMonad (ParserT s st m) where
382−
381+ lookupEnv = lift . lookupEnv
383−
382+ getCurrentTime = lift . getCurrentTime
384−
383+ getCurrentTimeZone = lift . getCurrentTimeZone
385−
384+ getDefaultReferenceDocx = lift . getDefaultReferenceDocx
385+ getDefaultReferenceODT = lift . getDefaultReferenceODT
386+ newStdGen = lift . newStdGen
387+ newUniqueHash = lift . newUniqueHash
388+ readFileLazy = lift . readFileLazy
389+ readDataFile mbuserdir = lift . readDataFile mbuserdir
390+ fail = lift . fail
391+ fetchItem media = lift . fetchItem media
392+ fetchItem' media sourceUrl = lift . fetchItem' media sourceUrl
393+ glob = lift . glob
394+ getModificationTime = lift . getModificationTime
395+-}
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -238,7 +238,7 @@ inline = (mempty <$ comment)
238 <|> (str . (:[]) <$> tildeEscape)
238 <|> (str . (:[]) <$> tildeEscape)
239 <|> (do res <- oneOf "#&~^'`\"[]"
239 <|> (do res <- oneOf "#&~^'`\"[]"
240 pos <- getPosition
240 pos <- getPosition
241− warningWithPos (Just pos) ("Parsing unescaped '" ++ [res] ++ "'")
241+ warningWithPos pos ("Parsing unescaped '" ++ [res] ++ "'")
242 return $ str [res])
242 return $ str [res])
243
243
244inlines :: PandocMonad m => LP m Inlines
244inlines :: PandocMonad m => LP 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.warningWithPos (Just pos) "YAML header is not an object"
283+ P.warningWithPos 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.warningWithPos (Just $ setSourceLine
294+ P.warningWithPos (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.warningWithPos (Just pos)
300+ _ -> P.warningWithPos 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.warningWithPos (Just pos) $ "Duplicate link reference `" ++ raw ++ "'"
423+ Just _ -> P.warningWithPos 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.warningWithPos (Just pos) $ "Duplicate note reference `" ++ ref ++ "'"
489+ Just _ -> P.warningWithPos 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+2−2
@@ -696,7 +696,7 @@ directive' = do
696 return $ B.divWith attrs children
696 return $ B.divWith attrs children
697 other -> do
697 other -> do
698 pos <- getPosition
698 pos <- getPosition
699− P.warningWithPos (Just pos) $ "ignoring unknown directive: " ++ other
699+ P.warningWithPos pos $ "ignoring unknown directive: " ++ other
700 return mempty
700 return mempty
701
701
702-- TODO:
702-- TODO:
@@ -1135,7 +1135,7 @@ renderRole contents fmt role attr = case role of
1135 renderRole contents newFmt newRole newAttr
1135 renderRole contents newFmt newRole newAttr
1136 Nothing -> do
1136 Nothing -> do
1137 pos <- getPosition
1137 pos <- getPosition
1138− P.warningWithPos (Just pos) $ "ignoring unknown role :" ++ custom ++ ": in"
1138+ P.warningWithPos pos $ "ignoring unknown role :" ++ custom ++ ": in"
1139 return $ B.str contents -- Undefined role
1139 return $ B.str contents -- Undefined role
1140 where
1140 where
1141 titleRef ref = return $ B.str ref -- FIXME: Not a sensible behaviour
1141 titleRef ref = return $ B.str ref -- FIXME: Not a sensible behaviour