quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.95k stars 325 forks source link

mermaid: forward options from YAML metadata to code cell initialization directives #6064

Open aphalo opened 1 year ago

aphalo commented 1 year ago

Within a Quarto .qmd file the directive that works here in GitHub (see below) and in the Mermaid interactive editor, is ignored when rendering a .qmd file to HTML (from within RStudio under Windows 10). This affects the whole of my website when rebuilt, but was working some/several weeks ago. Is there any quick workaround to get the directive obeyed? e.g., downgrading Quarto to some earlier version?

2023-06-29 11_24_50-~_RPackages_r4p-blog - master - RStudio

%%{init: {"htmlLabels": true} }%%

flowchart LR
  A(<i>model formula</i>) --> B[model fit\nfunction] --> C(model fit\nobject) --> D1['diagnostics' plots]
  AA(<i>observations</i>) --> B
  C --> D2[query methods]

The same code as an embed in this message renders correctly.

%%{init: {"htmlLabels": true} }%%

flowchart LR
  A(<i>model formula</i>) --> B[model fit\nfunction] --> C(model fit\nobject) --> D1['diagnostics' plots]
  AA(<i>observations</i>) --> B
  C --> D2[query methods]
dmi3kno commented 1 year ago

HTML labels is a flowchart property. It should be one level deeper in config.

%%{init:{"flowchart": {"htmlLabels": true}}}%%

flowchart LR
  A(<i>model formula</i>) --> B[model fit\nfunction] --> C(model fit\nobject) --> D1['diagnostics' plots]
  AA(<i>observations</i>) --> B
  C --> D2[query methods]

I understand that the strategy is to expose directives in YAML. This could be implemented as

---
title: "Untitled"
format: 
   html:
     mermaid: 
       theme: default
       flowchart:
         htmlLabels: true
---

Ref quarto-dev/quarto-cli#6209

aphalo commented 1 year ago

Thanks! Seems to be already working in the pre-release of Quarto 1.4, at least in 1.4.176

cderv commented 1 year ago

Seems to be already working in the pre-release of Quarto 1.4, at least in 1.4.176

Awesome ! Thanks for the update. I'll close this issue then !

dmi3kno commented 1 year ago

May I clarify what is working @aphalo? The init string or the YAML specification? Either way, it deserves to be documented. When doing so, can you, @cderv mention that htmlLabels is required both for HTML notation in nodes, as well as for the use of classDef clause.

cderv commented 1 year ago

Let me reopen then to let @aphalo answer

dmi3kno commented 1 year ago

The init string works in earlier versions of Quarto (and arguably has always worked, provided that htmlLabels is indicated under the flowchart property, i.e. on the second level). I would love to see the init string fully supported in YAML, but I understand that it might be a stretch target.