raghur / mermaid-filter

Pandoc filter for creating diagrams in mermaid syntax blocks in markdown docs
423 stars 75 forks source link

Set meta-data from command-line? #127

Closed aubertc closed 4 months ago

aubertc commented 5 months ago

If I process the following:

```{.mermaid caption="Test 1, 2"}
---
title: Bank example
---
classDiagram
class BankAccount
BankAccount : +String owner
BankAccount : +Bigdecimal balance
BankAccount : +deposit(amount)
BankAccount : +withdrawal(amount) 
```

using

pandoc -t html  -F mermaid-filter -o something.html test.md 

Then I obtain in my html file the alt="Test 1, 2" bit that is specified by the caption.

But if I remove caption="Test 1, 2" from the previous file, and process it using

pandoc -t html --metadata=MERMAID_FILTER_CAPTION:"Test 1, 2"  -F mermaid-filter -o something.html test.md 

then I don't obtain the alt indication in the html file. What am I missing? I have tried with the -M MERMAID_FILTER_CAPTION:"Test" syntax as well, but I simply cannot pass those meta-data from the command line using mermaid-filter.

aubertc commented 4 months ago

Ok, https://github.com/raghur/mermaid-filter/issues/96 clarified it: it's not a pandoc variable, but an environment variable.

On Unix systems, the command needs to be something along the lines of

export MERMAID_FILTER_CAPTION='Test' && pandoc -t html -F mermaid-filter -o something.html test.md