Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\today in date metadata #2865

Closed
ickc opened this issue Apr 20, 2016 · 10 comments
Closed

\today in date metadata #2865

ickc opened this issue Apr 20, 2016 · 10 comments

Comments

@ickc
Copy link
Contributor

ickc commented Apr 20, 2016

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!

@KurtPfeifle
Copy link

@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".)

@jgm
Copy link
Owner

jgm commented Apr 20, 2016

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 GitHub

References

  1. \today in date metadata #2865

@ickc
Copy link
Contributor Author

ickc commented Apr 21, 2016

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.

@ickc ickc closed this as completed Apr 21, 2016
@ickc
Copy link
Contributor Author

ickc commented Oct 3, 2016

Just to document it: to replicated the \today output LaTeX used,

-M date="`date "+%B%e, %Y"`"

should be used with pandoc.

@ickc
Copy link
Contributor Author

ickc commented Oct 29, 2016

Correction:

-M date="`date "+%B %e, %Y"`"

Do you mind if I add this in the MANUAL as an example?

@jgm
Copy link
Owner

jgm commented Oct 29, 2016

I'd rather not have it in the manual, since it's unix specific.

@hyiltiz
Copy link

hyiltiz commented Aug 10, 2017

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.

@ickc
Copy link
Contributor Author

ickc commented Aug 10, 2017

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.

@tarleb
Copy link
Collaborator

tarleb commented Aug 11, 2017

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.

@joelparkerhenderson
Copy link

joelparkerhenderson commented Feb 23, 2019

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'`" 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants