pandoc-ext / diagram

Generate diagrams from embedded code; supports Mermaid, Dot/GraphViz, PlantUML, Asymptote, and TikZ.
MIT License
53 stars 9 forks source link

Problem integration with Quarto #7

Closed FabienSe closed 1 year ago

FabienSe commented 1 year ago

I tested diagram.lua with the following qmd file:

---
filters:
  - diagram.lua
diagram:
  cache: true
  cache-dir: .cache/plantuml
---

# Welcome for fun

```{.plantuml}
'| label: fig-auth
@startuml
Alice -> Bob: Authentication Request Bob  super --> Alice: Authentication Response
Alice -> Bob: Another authentication Request Alice <-- Bob: another Response
@enduml

When I use the following command: `quarto render docs/index.qmd --to docx`, I get the following error:

```console
pandoc 
  to: docx
  output-file: index.docx
  default-image-extension: png

metadata
  diagram:
    cache: true
    cache-dir: .cache/plantuml

Error running filter /opt/quarto/share/filters/main.lua:
diagram.lua:11: attempt to call a nil value (global 'warn')
stack traceback:
        /opt/quarto/share/filters/main.lua:4073: in local 'callback'
        [string "..."]:1789: in function <[string "..."]:1787>
        (...tail calls...)
        /opt/quarto/share/filters/main.lua:368: in function 'make_wrapped_user_filters'
        /opt/quarto/share/filters/main.lua:15395: in main chunk

A workaround is to comment the following line

It happens with other output format too.

Quarto version used and pandoc version embedded by quarto. Tests was performed on WSL.

> 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.340
      Path: /opt/quarto/bin

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

Thanks for your help.

tarleb commented 1 year ago

Thank you, that's very interesting. I'll take a look.

tarleb commented 1 year ago

It appears that this was a bug in Quarto, as newer versions worked fine when I tested. Regardless, I made the filter more robust, so now it should work even with slightly older Quarto versions.

FabienSe commented 1 year ago

Cool, thanks for the fix!