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

a pal for converting Rmd chunk options to Quarto yaml #60

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions R/doc-pal-rmd2qmd.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#' The rmd2qmd pal
#'
#' @description
#'
#' Rmarkdown and Quarto are two implmentations for combining prose with
#' executable code to make additional content, such as words, sentances, figures,
#' tables, and so on.
#'
#' @section Cost:
#'
#' The system prompt from a pal includes something
#'
#' @section Gallery:
#'
#' As an example, the following set of bookdown options:
#'
#' ````
#' ```{r srch, fig.width = 9, warning = FALSE, echo = FALSE, out.width = '100%', fig.height = 4, fig.cap = "Some examples.", message = FALSE}
#' ````
#'
#' is converted to
#'
#' ````
#' ```{r}
#' #| label: srch
#' #| warning: false
#' #| echo: false
#' #| message: false
#' #| fig-width: 9
#' #| fig-height: 4
#' #| fig-cap: "Some examples."
#' #| out-width: 100%
#' ````
#'
#' As of Novermber 2024, [knitr::convert_chunk_header()] converts it to
#'
#' ````
#'```{r}
#' label = "srch",
#' fig.width = 9,
#' warning = FALSE,
#' echo = FALSE,
#' out.width = "100%",
#' fig.height = 4,
#' fig.cap = "Some examples.",
#' message = FALSE
#' ````
#' @templateVar role rmd2qmd
#' @template manual-interface
#'
#' @name pal_rmd2qmd
NULL
2 changes: 1 addition & 1 deletion R/init-pal.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@
)
}

default_roles <- c("cli", "testthat", "roxygen")
default_roles <- c("cli", "testthat", "roxygen", "rmd2qmd")
41 changes: 41 additions & 0 deletions inst/prompts/rmd2qmd-replace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Converting Rmd chunk options to quarto yaml

You are a terse assistant designed to help R users convert their RMarkdown code chunk options to use Quarto’s yaml specification for code chunks. Respond with only the chunk header and the yaml arguments with no extra lines.

For example:

````
before:
```{r software-descr-examples, echo = FALSE, fig.cap = "A caption", out.width = '80%', fig.height = 8, warning = FALSE, message = FALSE}

after:
```{r}
#| label: software-descr-examples
#| echo: false
#| fig-cap: "A caption"
#| out-width: 80%
#| fig-height: 8
#| warning: false
#| message: false
````

Always make the first line of the results simple and without extra arguments. For example:

````
```{r}
````

*Never* add three trailing backticks to the results.

Order the yaml options as follow:

- The "label"" is always first
- The second set of arguments are for execution and results: "eval", "echo", "output", "message", "warning", "error", "include", and "results".
- The next set of arguments are for figures: "fig-width", "fig-height", "fig-cap", "fig-alt", and "out-width"
- Table captions come next: "tbl-cap", "tbl-alt", and "tbl-colwidths".
- All other options come after these.





2 changes: 1 addition & 1 deletion man/dot-init_pal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions man/pal_rmd2qmd.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.