quarto-dev / quarto-cli

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

qmd file containing mermaid diagram cannot be rendered into a pdf file (Updated) #6481

Closed likanzhan closed 11 months ago

likanzhan commented 1 year ago

Bug description

No response

Steps to reproduce

  1. To build a minimal example, create a qmd file named intro.qmd, containing only the following mermaid code block:
```{mermaid}
graph TD
  A[ Anyone ] --> | Can help | B( Go to github.com/yuzutech/kroki )
  B --> C{ How to contribute? }
  C --> D[ Reporting bugs ]
  C --> E[ Sharing ideas ]
  C --> F[ Advocating ]

Here is the zipped [intro.qmd.zip](https://github.com/quarto-dev/quarto-cli/files/12327326/intro.qmd.zip) file

2. In the terminal, set the directory containing the qmd file as the current directory.
3. When I run `quarto preview intro.qmd` in the terminal, I can get the expected diagram in my browser. 
4. When I run `quarto render intro.qmd --to pdf` in the terminal, I expect to obtain an pdf file containing the diagram.
5. But the terminal is stuck in the command, no error is printed and no pdf file is obtained.

### Your environment

OS: MacOS Ventura 13.4.1 (c) 
chip: Apple M1 Max

### Quarto check output

```bash
quarto check

[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.1: OK
      Dart Sass version 1.55.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.3.450
      Path: /Applications/quarto/bin

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.10.12 (Conda)
      Path: /Users/likanzhan/.julia/conda/3/x86_64/bin/python
      Jupyter: 5.3.1
      Kernels: julia-1.8, julia-1.9, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.3.1
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
      knitr: 1.43
      rmarkdown: 2.22

[✓] Checking Knitr engine render......OK
mcanouil commented 1 year ago

Thanks for the report.

This seems to be a duplicate of:

cscheid commented 1 year ago

I'm on a very similar machine/OS and cannot reproduce this:

image image
likanzhan commented 1 year ago

@cscheid

Thanks for the responses. Is the format of your output PDF? Thanks

mcanouil commented 1 year ago

It is a PDF that is previewed in the screenshot.

likanzhan commented 1 year ago

@mcanouil @cscheid

Thanks, what could possibly be reason in my case?

mcanouil commented 1 year ago

Anything you did not tell us 🤷‍♂️ Your example is not a full Quarto document for starters. Make sure to try in a new empty directory.

Also, I am pretty sure Carlos is using TinyTex which can be installed by Quarto.

likanzhan commented 1 year ago

I didn't use TinyTex. But even if I used quarto install tool tinytex quarto install tool chromium to installed the two tools, the problem persists.

PS, I created a new empty directory.

mcanouil commented 1 year ago

@likanzhan I realise that your issue title mentioned "md" file but in your issue description you mentioned "qmd" files, also since you provided only mermaid code, your case is not reproducible as we might have try something different from what you do. Could you please provide a fully reproducible example and all the steps required to reproduce? Finally, if possible, could you try the latest pre-release version of Quarto?

likanzhan commented 1 year ago

@mcanouil, I've updated my description. Please let me know if there is more where I can make myself clearer. Furthermore, I've also tried the pre-release version of Quarto. The problem persists. Thanks.

cscheid commented 1 year ago

Is it possible that you don't have Chrome installed? That's one code path that could make a difference.

likanzhan commented 1 year ago

@cscheid. The chrome is installed. Here is an updated output of quarto check after I installed the prereleased quarto:

[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.6: OK
      Dart Sass version 1.55.0: OK
      Deno version 1.33.4: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.315
      Path: /Applications/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: v2023.08
      Chromium: 869685

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/likanzhan/Library/TinyTeX/bin/universal-darwin
      Version: 2023

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.10.12 (Conda)
      Path: /Users/likanzhan/.julia/conda/3/x86_64/bin/python
      Jupyter: 5.3.1
      Kernels: julia-1.9, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.3.1
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
      knitr: 1.43
      rmarkdown: 2.23

[✓] Checking Knitr engine render......OK
mcanouil commented 1 year ago

Would you be able to try in a Docker container? As currently we can't reproduce your issue, it's likely about something in your setup that causes this.

likanzhan commented 1 year ago

When I intend to draw the diagram with the julia interface:

```{julia}
using Kroki
Diagram(:mermaid, """
graph TD
  A[ Anyone ] --> | Can help | B( Go to github.com/yuzutech/kroki )
  B --> C{ How to contribute? }
  C --> D[ Reporting bugs ]
  C --> E[ Sharing ideas ]
  C --> F[ Advocating ]
""")

I got the following error:

FATAL (/Applications/quarto/share/filters/main.lua:4879) An error occurred: Could not convert a SVG to a PDF for output. Please ensure that rsvg-convert is available on the path.



Is this related to the problem when I use `mermaid` directly?

Thanks
mcanouil commented 1 year ago

Did you try to install the library and see if it solves the issue?

github-actions[bot] commented 1 year ago

Thank you for using Quarto and reporting an issue!

Unfortunately, this issue is now considered stale because it has been opened since 14 days without providing a "working" reproducible example to help us investigate. If you are still facing the issue, please review the "Bug Reports" guide on how to provide a fully reproducible example as a self-contained Quarto document or a link to a Git repository. Without a reproducible example, it is unlikely that the issue will be addressed.

You can share a Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four ````).

````qmd
---
title: "Reproducible Quarto Document"
format: html
---

This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded R code.
When you run the code, it will produce a plot.

```{r}
plot(cars)

The end.

cderv commented 1 year ago

When I intend to draw the diagram with the julia interface:

```{julia}
using Kroki
Diagram(:mermaid, """
graph TD
  A[ Anyone ] --> | Can help | B( Go to github.com/yuzutech/kroki )
  B --> C{ How to contribute? }
  C --> D[ Reporting bugs ]
  C --> E[ Sharing ideas ]
  C --> F[ Advocating ]
""")

I got the following error:

FATAL (/Applications/quarto/share/filters/main.lua:4879) An error occurred: Could not convert a SVG to a PDF for output. Please ensure that rsvg-convert is available on the path.



Is this related to the problem when I use `mermaid` directly?

Thanks

About this one @likanzhan , this is different than initial issue because

Using Julia, you could either

The initial issue is about PDF rendering of mermaid diagram through Quarto supports, this implies a Chrome print of the diagram to include as image. I believe this is where something is not right, and possibly a duplicate as already mentioned above: https://github.com/quarto-dev/quarto-cli/issues/6481#issuecomment-1672521910

cscheid commented 11 months ago

I'm closing this stale issue. Please reopen with the necessary information if you want to.