getT2TMeta: Take list of source files instead of single.

Get latest modification time.
This commit is contained in:
John MacFarlane 2014-07-30 17:25:00 -07:00
parent 3e26fb517d
commit 71e76175be
2 changed files with 9 additions and 10 deletions

View file

@ -69,7 +69,6 @@ import qualified Data.Yaml as Yaml
import qualified Data.Text as T
import Control.Applicative ((<$>))
import Text.Pandoc.Readers.Txt2Tags (getT2TMeta)
import Data.List (intersperse)
copyrightMessage :: String
copyrightMessage = "\nCopyright (C) 2006-2014 John MacFarlane\n" ++
@ -1070,11 +1069,10 @@ main = do
else e
Right w -> return w
let concatInput = concat (intersperse ", " sources)
reader <- if "t2t" == readerName'
then (mkStringReader .
readTxt2Tags) <$>
(getT2TMeta concatInput outputFile)
(getT2TMeta sources outputFile)
else case getReader readerName' of
Right r -> return r
Left e -> err 7 e

View file

@ -70,14 +70,15 @@ instance Default T2TMeta where
def = T2TMeta "" "" "" ""
-- | Get the meta information required by Txt2Tags macros
getT2TMeta :: FilePath -> FilePath -> IO T2TMeta
getT2TMeta inp out = do
getT2TMeta :: [FilePath] -> FilePath -> IO T2TMeta
getT2TMeta inps out = do
curDate <- formatTime defaultTimeLocale "%F" <$> getZonedTime
let getModTime = formatTime defaultTimeLocale "%F"
<$> getModificationTime inp
curMtime <- catchIOError getModTime (const (return ""))
return $ T2TMeta curDate curMtime inp out
let getModTime = fmap (formatTime defaultTimeLocale "%F") .
getModificationTime
curMtime <- catchIOError
(maximum <$> mapM getModTime inps)
(const (return ""))
return $ T2TMeta curDate curMtime (intercalate ", " inps) out
-- | Read Txt2Tags from an input string returning a Pandoc document
readTxt2Tags :: T2TMeta -> ReaderOptions -> String -> Pandoc