I found that if I do this in the YAML metadata:
date: \today
In latex output it will leaves it as is, so latex will then be able to substitute today there. But I'm not sure if it will break anything in other output formats. e.g. ePub.
Can someone confirm if this is good or not? And if not, what's the way to let pandoc set date to the date of compilation automatically?
Thanks!
@ickc: Can't you confirm (or disprove) that it breaks by just constructing a minimal Markdown file and include your YAML, and then let Pandoc create an EPUB (and all the other output formats you're interested in)?
(My bet is on the side that _"This is not working for other output formats"_.)
It will only work in LaTeX/PDF.
Your best bet is to set the date on the command line,
e.g.
--metadata date="`date +%D`"
on linux/unix.
+++ ickc [Apr 20 16 02:27 ]:
I found that if I do this in the YAML metadata:
date: \today
In latex output it will leaves it as is, so latex will then be able to
substitute today there. But I'm not sure if it will break anything in
other output formats. e.g. ePub.Can someone confirm if this is good or not? And if not, what's the way
to let pandoc set date to the date of compilation automatically?Thanks!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or [1]view it on GitHubReferences
Your best bet is to set the date on the command line,
Good idea. May be it can be put in the documentation as a trick worth nothing?
I am used to MultiMarkdown that if I don't specify a date, it will auto added today there. That's why I have such question.
Thanks and I'm closing it now.
Just to document it: to replicated the \today output LaTeX used,
-M date="`date "+%B%e, %Y"`"
should be used with pandoc.
Correction:
-M date="`date "+%B %e, %Y"`"
Do you mind if I add this in the MANUAL as an example?
I'd rather not have it in the manual, since it's unix specific.
Why don't we put in the MANUAL something that is NOT unix specific? First off, it is not unix specific, but rather POSIX specific, including much more than unix. Then we can also write down what works for Windows users. I assume POSIX+Windows covers 99.99% of the users of pandoc.
I assume POSIX+Windows covers 99.99% of the users of pandoc.
Interesting statement: would pandoc even work if it's not "POSIX+Windows"?
I think what @jgm means is this is not something pandoc "officially" covered. e.g. nothing within pandoc really can help you to create today in date. So what that did is "a hack" that's outside the scope of pandoc. I guess the manual is already very long, so he don't want to add more unnecessary stuffs there.
Some tricks like this is added in Pandoc Tricks · jgm/pandoc Wiki. Perhaps I should put this there as well.
FWIW: lua filters will allow to set the date like this in a fully portable manner:
function Meta(m)
m.date = os.date("%B %e, %Y")
return m
end
Note to self: Might be a good example to add to the docs.
To set the date in YYYY-MM-DD UTC ISO standard format, this syntax works on macOS for me:
--metadata date="`date -u '+%Y-%m-%d'`"
Most helpful comment
To set the date in YYYY-MM-DD UTC ISO standard format, this syntax works on macOS for me: