diff options
author | Jesse Rosenthal <jrosenthal@jhu.edu> | 2016-11-28 17:13:46 -0500 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-01-25 17:07:40 +0100 |
commit | b53ebcdf8e8e1f7098a0c93ead4b5bf99971c77f (patch) | |
tree | 01e8d78b85f68e88a737baec9e6bbc932f0a84be /src/Text/Pandoc/Class.hs | |
parent | 840439ab2a4d44bc4d295df0d66003fbcc9bb18e (diff) | |
download | pandoc-b53ebcdf8e8e1f7098a0c93ead4b5bf99971c77f.tar.gz |
Working on readers.
Diffstat (limited to 'src/Text/Pandoc/Class.hs')
-rw-r--r-- | src/Text/Pandoc/Class.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs index 12e6f900b..5cef621dc 100644 --- a/src/Text/Pandoc/Class.hs +++ b/src/Text/Pandoc/Class.hs @@ -35,6 +35,7 @@ module Text.Pandoc.Class ( PandocMonad(..) , PureState(..) , PureEnv(..) , getPOSIXTime + , addWarningWithPos , PandocIO(..) , PandocPure(..) , PandocExecutionError(..) @@ -57,6 +58,7 @@ import qualified Text.Pandoc.Shared as IO ( fetchItem , warn , readDataFile) import Text.Pandoc.Compat.Time (UTCTime) +import Text.Pandoc.Parsing (ParserT, ParserState, SourcePos) import qualified Text.Pandoc.Compat.Time as IO (getCurrentTime) import Data.Time.Clock.POSIX ( utcTimeToPOSIXSeconds , posixSecondsToUTCTime @@ -109,6 +111,14 @@ class (Functor m, Applicative m, Monad m, MonadError PandocExecutionError m) => getPOSIXTime :: (PandocMonad m) => m POSIXTime getPOSIXTime = utcTimeToPOSIXSeconds <$> getCurrentTime +addWarningWithPos :: PandocMonad m + => Maybe SourcePos + -> String + -> ParserT [Char] ParserState m () +addWarningWithPos mbpos msg = + lift $ + warn $ + msg ++ maybe "" (\pos -> " " ++ show pos) mbpos -- We can add to this as we go data PandocExecutionError = PandocFileReadError FilePath |