mermaid-filter icon indicating copy to clipboard operation
mermaid-filter copied to clipboard

#fig:reference doesn't work if caption isn't provided

Open jbree opened this issue 5 years ago • 7 comments

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}

jbree avatar Nov 26 '19 18:11 jbree

Can you share the command you're testing with?

raghur avatar Feb 24 '20 08:02 raghur

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.

jbree avatar Feb 27 '20 22:02 jbree

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
```

jbree avatar Mar 06 '20 03:03 jbree

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.

dtbuchholz avatar May 12 '23 17:05 dtbuchholz

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.

@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 avatar Sep 02 '23 18:09 ErrorTzy

@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

dtbuchholz avatar Sep 07 '23 20:09 dtbuchholz

@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.

andreilgeorgescu avatar Nov 07 '23 22:11 andreilgeorgescu