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

View file

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