pandoc-ext / diagram

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

Using defaults file for settings not working #23

Closed gerstorfer closed 1 month ago

gerstorfer commented 1 month ago

I can set options for the filter in the yaml header of the file itself, in a metadata file but not in a defaults file. This is not a huge problem, I just wonder what goes wrong here.


This is not working:

test.md

## Simple example:

```tikz
% https://q.uiver.app/#q=WzAsMyxbMCwwLCJcXGJ1bGxldCJdLFsyLDAsIlxcYnVsbGV0Il0sWzIsMiwiXFxidWxsZXQiXSxbMCwxXSxbMCwyXSxbMSwyLCIiLDAseyJzdHlsZSI6eyJib2R5Ijp7Im5hbWUiOiJzcXVpZ2dseSJ9fX1dXQ==
\begin{tikzcd}[ampersand replacement=\&,cramped]
    \bullet \&\& \bullet \\
    \\
    \&\& \bullet
    \arrow[from=1-1, to=1-3]
    \arrow[from=1-1, to=3-3]
    \arrow[squiggly, from=1-3, to=3-3]
\end{tikzcd}
```

default.yaml

metadata:
  diagram:
    engine:
      tikz:
        header-includes:
          - '\usepackage{quiver}'

and: pandoc --lua-filter=diagram.lua test.md --defaults=./default.yaml -o test.pdf

Using the exact same settings in a metadata file works without problems:

metadata.yaml

diagram:
  engine:
    tikz:
      header-includes:
        - '\usepackage{quiver}'

and: pandoc --lua-filter=diagram.lua test.md --metadata-file=./metadata.yaml -o test.pdf

tarleb commented 1 month ago

I'm guessing that what's happening here is that YAML strings in the defaults file are treated as plain strings, while those in the metadata file are treated as Markdown. That difference leads to issues somewhere along the way. I can take a look if there's something we can do.

tarleb commented 1 month ago

Can you try with additional-packages instead of header-includes? I see that the filter treats those slightly differently, with the latter being more in line with what you need.

gerstorfer commented 1 month ago

Yes, that works just fine!