pandoc-ext / diagram

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

additional packages for tikz #2

Closed lsignac closed 1 year ago

lsignac commented 1 year ago

It seems to me that additional packages for tikz are not taken into account. sample.md contains :

   {.tikz caption="This is an image, created by **TikZ i.e. LaTeX**."   additionalPackages="\usepackage{adjustbox}"}

but in diagram.lua :

local pkgs = opt['additional-packages'] or ''

variable pkgs remains empty (opt['additional-packages'] is nil). The package is not added, and compilation fails (missing \trimbox).

If I add \usepackage{adjustbox} directly in local tikz_template variable, everything works fine.

I don't understand lua enough to make a PR... :)

tarleb commented 1 year ago

That line should probably be local pkgs = opt['additional-packages'] or opt['additionalPackages'] or ''; the camelCase version was just not handled. One can also use additional-packages="..." for the time being.

lsignac commented 1 year ago

I tried opt['additionalPackages'] in diagram.lua before opening this issue and it did not work. My conclusion was that I did not understand the opt[...] thing. Writing additional-packages instead of additionalPackages in the markdown file does not work either (I tried with the sample.md you provided (camelCase)).

tarleb commented 1 year ago

You're right, I forgot that I changed this to opt-additional-packages. The docs have not been updated yet.

lsignac commented 1 year ago

Got it... ! You sample.md file contains :

    ```{.tikz caption="This is an image, created by **TikZ i.e. LaTeX**."
        additionalPackages="\usepackage{adjustbox}"}
    ...

But it should be :

    ```{.tikz caption="This is an image, created by **TikZ i.e. LaTeX**."
        opt-additional-packages="\usepackage{adjustbox}"}
    ...
lsignac commented 1 year ago

Oh... too late :)

tarleb commented 1 year ago

The real reference files are those named test/input-*.md now. I'll remove sample.md.

lsignac commented 1 year ago

Not sure that test/input-*.md are good for the final user. The first thing I did when I found your filter was trying to compile a sample file to check that the filter matched my needs. (It matched). I close the issue. Thank you for your work and you blazingly fast answers