Skip to content

Conversation

@bastienchassagnol
Copy link

@bastienchassagnol bastienchassagnol commented Sep 13, 2025

Summary

Add Quarto minimal reprex tests, as the behaviour of Quarto documents differ from RMarkdown

Changes

  • Modified function R/latex_str.R paired with R/get_pdf_engine to support Quarto output.
  • Added unit tests: tests/testthat/qmd/use-printer-with-pdflatex.qmd

Rationale

Depending on the pdf-engine YAML option, you should not load fontspec package -> In quarto equally to Rmarkdown, the pdf-engine should be processed -> the differences between the two formats mostly lie in the way metadata for an individual quarto document is stored, see quarto-dev/quarto-cli#13371 for additional details.

Related

Fixes #701

Notes for maintainers

  • If you want me to squash commits, I can do that.
  • Interactive Debugging for Quarto is kinda stupid, requires calling rmarkdown::render, instead of quarto::quarto_render() -> however, doing this, you can't reproduce the error.

@bastienchassagnol bastienchassagnol marked this pull request as draft September 13, 2025 13:41
@bastienchassagnol bastienchassagnol marked this pull request as ready for review September 13, 2025 19:33
@bastienchassagnol
Copy link
Author

bastienchassagnol commented Sep 13, 2025

Current solution proposed is working, however, I've listed the following tracks of improvement:

  • Add automated testing for qmd generation, inspiring from ./tests/testthat/test-borders.R
  • Rewrite following code to make it more compact, and avoid nested if loops
  • Compare with Rmardkown parsing approaches listed here
  • Test, and add support for pdf-engine: tectonic, latexmk, as Quarto also accomodates for them -> do not know if they are compliant, or not with the fontspec package.
  if (length(rd)) {
    engine <- pandoc_args[rd + 1]
  } else if (is_in_quarto()) {
    # retrieve pdf engine if available
    engine <- rmarkdown::metadata$format$pdf$`pdf-engine`
    if (is.null(engine) || engine == "") {
      engine <- "xelatex"
    }
  } else {
    engine <- "pdflatex"
  }

@eli-daniels
Copy link
Collaborator

eli-daniels commented Oct 8, 2025

Hello @bastienchassagnol, thanks for the PR.

  1. Its really hard to see what changes have been made due to the code formatting edits. Could you remove those please, then happy to review.
  2. From a quick look you removed is_quarto, make sure to keep this.

@bastienchassagnol
Copy link
Author

Hi @eli-daniels — great to hear from you!

I’ll do my best to incorporate all the suggested changes. I have two quick comments:

  • Debugging while rendering to Quarto: Do you have any recommendations for streamlining debugging in interactive mode? It seems that, for now, the native RStudio debugger isn’t supported during Quarto rendering.

  • Regarding formatting differences:: I was initially surprised by the number of detected changes, as the edits I made were quite limited. On second thought, most differences are related to the use of [air](https://posit-dev.github.io/air/), the now-recommended formatter for R code. I’ve configured it to automatically restyle files on save — I can temporarily disable that option if preferred.

That said, @eli-daniels and @davidgohel, I’d be interested in your thoughts on the air formatter compared with the more traditional styler approach.

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

Successfully merging this pull request may close these issues.

Bad assumption of Quarto engine

2 participants