pandoc-ext / diagram

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

Error when ther if no caption and no alt #4

Closed lsignac closed 1 year ago

lsignac commented 1 year ago

Including simple images instead of figure where there is no caption is very useful.
But when if I provide neither caption nor alt, there is an error message :

pandoc -t latex --lua-filter ~/dev/pandoc/diagram.lua -o test.pdf  test.md 

Error running filter diagram.lua:
Inline, list of Inlines, or string expected, got nil
    while retrieving function argument caption
    while retrieving arguments for function Image
stack traceback:
    diagram.lua:481: in function <diagram.lua:413>
    [C]: in ?
    [C]: in method 'walk'
    diagram.lua:497: in function 'Pandoc'
stack traceback:
    diagram.lua:497: in function 'Pandoc'

Sample file:

  Sample graph :

  ```{.dot}
  digraph {
    A -> B;
    B -> C;
    C -> A;
  }
  ```

If I use {.dot alt="foo"} or {.dot caption="bar"}, everything is fine.

tarleb commented 1 year ago

Thanks for the report!