aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/RST.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-04-12 10:32:38 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-04-12 10:32:38 -0700
commitbf583c3d9cc70f45390b79b21bba788536a1aaac (patch)
treecf2a68ff09120494af4a902e34840bb0363ce27f /src/Text/Pandoc/Readers/RST.hs
parent9187b4bca9fc42ad7ca865d1e691664a463c8924 (diff)
downloadpandoc-bf583c3d9cc70f45390b79b21bba788536a1aaac.tar.gz
RST reader: handle "date::" directive.
Closes #6276.
Diffstat (limited to 'src/Text/Pandoc/Readers/RST.hs')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index ea13f62dc..430d24f4a 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -27,7 +27,8 @@ import Data.Text (Text)
import qualified Data.Text as T
import Text.Pandoc.Builder (Blocks, Inlines, fromList, setMeta, trimInlines)
import qualified Text.Pandoc.Builder as B
-import Text.Pandoc.Class.PandocMonad (PandocMonad, fetchItem, readFileFromDirs)
+import Text.Pandoc.Class.PandocMonad (PandocMonad, fetchItem,
+ readFileFromDirs, getCurrentTime)
import Text.Pandoc.CSV (CSVOptions (..), defaultCSVOptions, parseCSV)
import Text.Pandoc.Definition
import Text.Pandoc.Error
@@ -38,6 +39,7 @@ import Text.Pandoc.Parsing
import Text.Pandoc.Shared
import qualified Text.Pandoc.UTF8 as UTF8
import Text.Printf (printf)
+import Data.Time.Format
-- TODO:
-- [ ] .. parsed-literal
@@ -682,6 +684,13 @@ directive' = do
parseFromString' parseBlocks body'
"replace" -> B.para <$> -- consumed by substKey
parseInlineFromText (trim top)
+ "date" -> B.para <$> do -- consumed by substKey
+ t <- getCurrentTime
+ let format = case T.unpack (T.strip top) of
+ [] -> "%Y-%m-%d"
+ x -> x
+ return $ B.text $
+ T.pack $ formatTime defaultTimeLocale format t
"unicode" -> B.para <$> -- consumed by substKey
parseInlineFromText (trim $ unicodeTransform top)
"compound" -> parseFromString' parseBlocks body'