aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Class.hs34
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs2
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs10
-rw-r--r--src/Text/Pandoc/Readers/RST.hs4
4 files changed, 30 insertions, 20 deletions
diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs
index d81d3b68b..5121d3fe6 100644
--- a/src/Text/Pandoc/Class.hs
+++ b/src/Text/Pandoc/Class.hs
@@ -72,7 +72,7 @@ import qualified Text.Pandoc.Shared as IO ( fetchItem
, readDataFile
, warn)
import Text.Pandoc.Compat.Time (UTCTime)
-import Text.Pandoc.Parsing (ParserT, ParserState, SourcePos)
+import Text.Pandoc.Parsing (ParserT, SourcePos)
import qualified Text.Pandoc.Compat.Time as IO (getCurrentTime)
import Data.Time.Clock.POSIX ( utcTimeToPOSIXSeconds
, posixSecondsToUTCTime
@@ -121,7 +121,7 @@ class (Functor m, Applicative m, Monad m, MonadError PandocError m, MonadState C
glob :: String -> m [FilePath]
getModificationTime :: FilePath -> m UTCTime
-
+
-- Functions defined for all PandocMonad instances
@@ -157,11 +157,10 @@ getZonedTime = do
return $ utcToZonedTime tz t
warningWithPos :: PandocMonad m
- => Maybe SourcePos
+ => SourcePos
-> String
- -> ParserT [Char] ParserState m ()
-warningWithPos mbpos msg =
- lift $ warning $ msg ++ maybe "" (\pos -> " " ++ show pos) mbpos
+ -> ParserT s st m ()
+warningWithPos pos msg = lift $ warning $ msg ++ " " ++ show pos
--
@@ -377,9 +376,20 @@ instance PandocMonad PandocPure where
Just tm -> return tm
Nothing -> throwError $ PandocFileReadError fp
-
-
-
-
-
-
+{-
+instance PandocMonad m => PandocMonad (ParserT s st m) where
+ lookupEnv = lift . lookupEnv
+ getCurrentTime = lift . getCurrentTime
+ getCurrentTimeZone = lift . getCurrentTimeZone
+ getDefaultReferenceDocx = lift . getDefaultReferenceDocx
+ getDefaultReferenceODT = lift . getDefaultReferenceODT
+ newStdGen = lift . newStdGen
+ newUniqueHash = lift . newUniqueHash
+ readFileLazy = lift . readFileLazy
+ readDataFile mbuserdir = lift . readDataFile mbuserdir
+ fail = lift . fail
+ fetchItem media = lift . fetchItem media
+ fetchItem' media sourceUrl = lift . fetchItem' media sourceUrl
+ glob = lift . glob
+ getModificationTime = lift . getModificationTime
+-}
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 49d2d702f..1c8536924 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -238,7 +238,7 @@ inline = (mempty <$ comment)
<|> (str . (:[]) <$> tildeEscape)
<|> (do res <- oneOf "#&~^'`\"[]"
pos <- getPosition
- warningWithPos (Just pos) ("Parsing unescaped '" ++ [res] ++ "'")
+ warningWithPos pos ("Parsing unescaped '" ++ [res] ++ "'")
return $ str [res])
inlines :: PandocMonad m => LP m Inlines
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 012edfe3b..1923bca01 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -280,7 +280,7 @@ yamlMetaBlock = try $ do
) nullMeta hashmap
Right Yaml.Null -> return nullMeta
Right _ -> do
- P.warningWithPos (Just pos) "YAML header is not an object"
+ P.warningWithPos pos "YAML header is not an object"
return nullMeta
Left err' -> do
case err' of
@@ -291,13 +291,13 @@ yamlMetaBlock = try $ do
yamlLine = yline
, yamlColumn = ycol
}}) ->
- P.warningWithPos (Just $ setSourceLine
+ P.warningWithPos (setSourceLine
(setSourceColumn pos
(sourceColumn pos + ycol))
(sourceLine pos + 1 + yline))
$ "Could not parse YAML header: " ++
problem
- _ -> P.warningWithPos (Just pos)
+ _ -> P.warningWithPos pos
$ "Could not parse YAML header: " ++
show err'
return nullMeta
@@ -420,7 +420,7 @@ referenceKey = try $ do
let oldkeys = stateKeys st
let key = toKey raw
case M.lookup key oldkeys of
- Just _ -> P.warningWithPos (Just pos) $ "Duplicate link reference `" ++ raw ++ "'"
+ Just _ -> P.warningWithPos pos $ "Duplicate link reference `" ++ raw ++ "'"
Nothing -> return ()
updateState $ \s -> s { stateKeys = M.insert key (target, attr') oldkeys }
return $ return mempty
@@ -486,7 +486,7 @@ noteBlock = try $ do
let newnote = (ref, parsed)
oldnotes <- stateNotes' <$> getState
case lookup ref oldnotes of
- Just _ -> P.warningWithPos (Just pos) $ "Duplicate note reference `" ++ ref ++ "'"
+ Just _ -> P.warningWithPos pos $ "Duplicate note reference `" ++ ref ++ "'"
Nothing -> return ()
updateState $ \s -> s { stateNotes' = newnote : oldnotes }
return mempty
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 92d0e8670..82e50ce6e 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -696,7 +696,7 @@ directive' = do
return $ B.divWith attrs children
other -> do
pos <- getPosition
- P.warningWithPos (Just pos) $ "ignoring unknown directive: " ++ other
+ P.warningWithPos pos $ "ignoring unknown directive: " ++ other
return mempty
-- TODO:
@@ -1135,7 +1135,7 @@ renderRole contents fmt role attr = case role of
renderRole contents newFmt newRole newAttr
Nothing -> do
pos <- getPosition
- P.warningWithPos (Just pos) $ "ignoring unknown role :" ++ custom ++ ": in"
+ P.warningWithPos pos $ "ignoring unknown role :" ++ custom ++ ": in"
return $ B.str contents -- Undefined role
where
titleRef ref = return $ B.str ref -- FIXME: Not a sensible behaviour