summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2022-02-10 19:17:20 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2022-02-10 19:17:20 -0800
commit97d83e383ad8889ea2003ce74f728d51e4bbb248 (patch)
treefa74abc0c6b0f2c4ad3824071cd41e1c4ae86474
parent03c602537938681123bbff7ee456c7fe93319f9f (diff)
LaTeX reader: support `\today`.
Closes #7905.
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 25459d8f8..e2b283cf2 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -36,10 +36,10 @@ import Skylighting (defaultSyntaxMap)
import System.FilePath (addExtension, replaceExtension, takeExtension)
import Text.Collate.Lang (renderLang)
import Text.Pandoc.Builder as B
-import Text.Pandoc.Class.PandocPure (PandocPure)
-import Text.Pandoc.Class.PandocMonad (PandocMonad (..), getResourcePath,
- readFileFromDirs, report,
- setResourcePath)
+import Text.Pandoc.Class (PandocPure, PandocMonad (..), getResourcePath,
+ readFileFromDirs, report,
+ setResourcePath, getZonedTime)
+import Data.Time (ZonedTime(..), LocalTime(..), showGregorian)
import Text.Pandoc.Error (PandocError (PandocParseError, PandocParsecError))
import Text.Pandoc.Highlighting (languagesByExtension)
import Text.Pandoc.ImageSize (numUnit, showFl)
@@ -422,8 +422,15 @@ inlineCommands = M.unions
, ("uline", underline <$> tok)
-- plain tex stuff that should just be passed through as raw tex
, ("ifdim", ifdim)
+ -- generally only used in \date
+ , ("today", today)
]
+today :: PandocMonad m => LP m Inlines
+today =
+ text . T.pack . showGregorian . localDay . zonedTimeToLocalTime
+ <$> getZonedTime
+
lettrine :: PandocMonad m => LP m Inlines
lettrine = do
optional rawopt