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

Have a flexible quarto_get_meta() #182

Closed
olivroy opened this issue May 20, 2024 · 4 comments
Closed

Have a flexible quarto_get_meta() #182

olivroy opened this issue May 20, 2024 · 4 comments
Labels
question Further information is requested

Comments

@olivroy
Copy link
Contributor

olivroy commented May 20, 2024

to be able to program around some things in the metadata from R

accessing the yaml metadata is currently difficult

@cderv
Copy link
Collaborator

cderv commented May 21, 2024

Can you give some use case and example of usage on how this would work ?

Quarto does not work as R Markdown and all the meta that will be used for Pandoc rendering won't be accessible on knitting time IMO.

So I want clarify what is expected here.

Let's remind that Quarto has some way to read the meta :

and an extensions mechanism through Lua Filters to compute on the Meta

Unless we are not talking on the same metadata.

Thanks

@cderv cderv added the question Further information is requested label May 21, 2024
@olivroy
Copy link
Contributor Author

olivroy commented May 21, 2024

In short, I'd like something that works 2 ways: (i.e. you set it in one place, and can use it as an r variable + quarto metadata.

I would just want to be able to use it as an R variable..

The meta shortcode is useful to print things, but not to manipulate it. I don'y know anything about lua, so I'd have to dig into it to find out more..

Let's say I want to read the date.

---
title: "A title"
date: 2024-03-22
---


```{r}
month <- lubridate(ym(get_meta("date")
```

The month is `r month`

Basically, I would like to be able to set something once (either as R code OR in yaml meta) and let quarto AND R use it.

Alternatively, if the following worked (I think it did in rmarkdown.

---
title: "A title"
date: 2024-03-22
---


```{r}
date <- "2024-03-22"
month <- lubridate::month(date)
```

---
date: !expr date
---

`r month`

@cderv
Copy link
Collaborator

cderv commented May 21, 2024

Basically, I would like to be able to set something once (either as R code OR in yaml meta) and let quarto AND R use it.

This would be a feature request to Quarto itself so that metadata are accessible using objects inside computation cells. It is not just a Quarto R package feature. This 📦 is only a wrapper around quarto CLI, which additional helpers for R users.

This is much more a feature that would need to work for all engine in Quarto (Jupyter, Knitr, Julia, ...)

You can probably open a discussion there about this, if none exists already

Alternatively, if the following worked (I think it did in rmarkdown.

This is about

It works today, you just need to drop the !expr which makes sense only for content your read from YAML in R. Here, you want to export from knitr rendering to Quarto processing.

---
title: "A title"
---


```{r}
date <- "2024-03-22"
month <- lubridate::month(date)
```

---
date: '`r date`'
---

`r month`

image

@olivroy
Copy link
Contributor Author

olivroy commented May 21, 2024

**It works today, you just need to drop the !expr which makes sense only for content your read from YAML in R. Here, you want to export from knitr rendering to Quarto processing.

I was sure I tried this, but it didn't work. I will browse quarto discussions / issues and link here if necessary!

Note that it works for date but not for format.

Thanks for the explanations.

Requested in quarto-dev/quarto-cli#10886. rmarkdown::metadata seems to work?

@olivroy olivroy closed this as not planned Won't fix, can't repro, duplicate, stale May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants