mermaid-filter
mermaid-filter copied to clipboard
#fig:reference doesn't work if caption isn't provided
Took me a while to figure out why pandoc-crossref wasn't working with mermaid-filter. Suggest updating the documentation.
It doesn't work with {.mermaid caption="reference-name"}
It doesn't work with {.mermaid #fig:reference-name}
It does work when they're combined: {.mermaid caption="Caption" #fig:reference-name}
Can you share the command you're testing with?
Sorry for the delay. It's been awhile, so I will try to reproduce tonight or within the next couple days and get back to you.
I generated using the following command:
pandoc mermaid-filter-test.md -o test.pdf -F mermaid-filter -F pandoc-crossref
This results in a document with the following text:
This test document references fig. 1 and fig. ??.
When given this test document:
This test document references @fig:hello and @fig:goodbye.
```{.mermaid #fig:hello caption="Say Hello"}
sequenceDiagram
participant A as Alice
participant B as Bob
A->>B: Hello
B->>A: Hello
```
```{.mermaid #fig:goodbye}
sequenceDiagram
participant A as Alice
participant B as Bob
A->>B: Goodbye
B->>A: Goodbye
```
I'm running into the same issue but am unable to use the workaround. Using the markdown above, it generates fig. ??
when referencing the diagram. I'm using the command below where my file is use-cases.md
and is being converted to a PDF:
pandoc -F mermaid-filter -F pandoc-crossref -M link-citations=true --citeproc use-cases.md --pdf-engine=pdflatex -o use-cases.pdf
Note the caption does not render, either.
I'm running into the same issue but am unable to use the workaround. Using the markdown above, it generates
fig. ??
when referencing the diagram. I'm using the command below where my file isuse-cases.md
and is being converted to a PDF:pandoc -F mermaid-filter -F pandoc-crossref -M link-citations=true --citeproc use-cases.md --pdf-engine=pdflatex -o use-cases.pdf
Note the caption does not render, either.
@dtbuchholz I'm also running into the same issue, and it seems to be an issue with pandoc. I'm not sure if @raghur can fix this, but if mermaid-filter is used with pandoc-crossref, mermaid-filter seems to work partially (i.e., theme parameter works, but caption and #fig:id does not, no matter they are combined or not). The workaround is that, when I execute
pandoc -F mermaid-filter use-cases.md -t markdown | pandoc -F pandoc-crossref -M link-citations=true --citeproc --pdf-engine=pdflatex -o use-cases.pdf
This outputs the desired result. I read some pandoc document, I guess it could be possible that when pandoc filter mermaid-filter have done some modification to pandoc AST, pandoc-crossref no longer recognize them as markdown syntax. But I'm only pulling this out of my ass.
(Windows 10, pandoc 3.1.6.2)
@ErrorTzy thanks for the heads up. i actually just tried running my original command, and now it works! fwiw, i'm on Mac M1 (OS 13.4.1) and am using pandoc 3.1.2
@jbree @ErrorTzy Thanks! Combining both of these suggestions was the only thing that worked for me.
It's probably for the best anyway to have a first pass just for mermaid-filter
and a second pass for everything else.