Skip to content

date keywords and formatting does not work in PDF #615

Closed

Description

@cderv
---
date: today
date-format: long #"MMMM DD, YYYY" # "`r format(Sys.Date(), '%B %d, %Y')`"
---

Does not seem to work for format: pdf. How does dynamic date work in pdf output?

quarto version: quarto-0.9.228-macos.pkg (Pkg)

Originally posted by @eyayaw in #452 (reply in thread)

Activity

  1. cderv commented on Apr 12, 2022

    @cderv
    MemberAuthor

    I can reproduce that with

    ---
    title: test
    author: "me"
    date: today
    date-format: long
    format: pdf
    ---
    
    # Hello
    
    World 

    image

  2. cderv commented on Apr 12, 2022

    @cderv
    MemberAuthor

    @dragonstyle is this supposed to be supported in other format than HTML yet ?

    It does not seem so as the magic happens in

    if (dateRaw) {
    const formatted = formattedDate(
    dateRaw,
    format.metadata[kDateFormat] as string || "long",
    );
    if (formatted) {
    dateEl.innerText = formatted;
    }
    const dateContainer = metadataEl(
    doc,
    localizedString(format, kTitleBlockPublished),
    [dateEl],
    );
    metadataContainerEl.appendChild(dateContainer);
    }

    so only for HTML

    For other formats it seems were are only doing

    // Resolve the date if there are any special
    // date specifiers
    if (isSpecialDate(allMetadata[kDate])) {
    allMetadata[kDate] = parseSpecialDate(
    input,
    allMetadata[kDate] as string,
    );
    }

    which does not take into accound date-format

    but this does not explain why today is shown in the PDF output instead of the resolved date 🤔

  3. eyayaw commented on Apr 12, 2022

    @eyayaw

    Thank you for taking the initiative, Christophe (@cderv).

  4. dragonstyle commented on Apr 12, 2022

    @dragonstyle
    Collaborator

    This is definitely not working as it should - I will take a look! Thanks for reporting it and digging in!

  5. pat-alt commented on Apr 13, 2022

    @pat-alt

    I also just stumbled across this. Not sure if helpful, but I've noted that date keywords (kind of) work for PDF output inside a quarto project. Only kind of, because the date-format has no effect. Have created a minimum working example here.

  6. cderv commented on Apr 13, 2022

    @cderv
    MemberAuthor

    Thanks @pat-alt, it means the project structure is directly related. This is not the first case where something works differently on Project vs single file.

    @dragonstyle If you want me to have a deeper look, I can do it.

  7. dragonstyle commented on Apr 14, 2022

    @dragonstyle
    Collaborator

    I should have a fix in for this tomorrow AM! I'll post here when its ready...

  8. self-assigned this
    on Apr 14, 2022
  9. dragonstyle commented on Apr 14, 2022

    @dragonstyle
    Collaborator

    Jus building a release that should have the changes the make this work seamlessly across any format...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions