Can't render PDF or docx of a quarto file with Mermaid diagram

I've been trying to do this in R Studio (v 2024.12.0 Build 467) on Mac OS, and at first it would just hang as a background job. Then, looking all over the internet including this forum, I saw that this was a widespread issue. I updated my quarto to 1.6.40 and then updated my chromium using "quarto install chromium" at terminal. Then it resulted in an ERROR when trying to render to PDF - something like " ERROR: Couldn't find open server. Chrome process error: Old Headless mode. . . " I then updated my quarto to 1.7.13, and also updated my tinytex installation, and now it's back to just hanging indefinitely in the background jobs. Bottom line, I want to be able to render my quarto document to PDF or docx if it contains a Mermaid diagram. Rendering it to HTML is insufficient, as I need to access an image (jpeg, png, tiff etc) of the diagram to put in a document.

This works for me in Rstudio 2024.12.0+467 under OS X 15.3 Quarto version 1.6.0 and tiny text 0.54

---
title: "Untitled"
format: docx
---

```{r}
# Create a simple graph running left to right (note
# that the whitespace is not important)
DiagrammeR("
  graph LR
    A-->B
    A-->C
    C-->E
    B-->D
    C-->D
    D-->F
    E-->F
")
    ```

Thanks! I got your R code to work after I installed the package "webshot2." However, it still doesn't work with my Mermaid code, and still gets held up. I need it to work with Mermaid, as DiagrammeR is too basic.