From 71e76175be8a5fabb807a8462a1ab315868c8914 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 30 Jul 2014 17:25:00 -0700 Subject: [PATCH] getT2TMeta: Take list of source files instead of single. Get latest modification time. --- pandoc.hs | 4 +--- src/Text/Pandoc/Readers/Txt2Tags.hs | 15 ++++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pandoc.hs b/pandoc.hs index 2cd161907..b3da9b8b1 100644 --- a/pandoc.hs +++ b/pandoc.hs @@ -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 diff --git a/src/Text/Pandoc/Readers/Txt2Tags.hs b/src/Text/Pandoc/Readers/Txt2Tags.hs index 8d8af309e..3a51b9d84 100644 --- a/src/Text/Pandoc/Readers/Txt2Tags.hs +++ b/src/Text/Pandoc/Readers/Txt2Tags.hs @@ -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