Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jbree opened this issue Nov 26, 2019 · 7 comments
Open

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

jbree opened this issue Nov 26, 2019 · 7 comments

Comments

@jbree
Copy link

jbree commented Nov 26, 2019

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}

@raghur
Copy link
Owner

raghur commented Feb 24, 2020

Can you share the command you're testing with?

@jbree
Copy link
Author

jbree commented Feb 27, 2020

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
Copy link
Author

jbree commented Mar 6, 2020

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

@dtbuchholz
Copy link

dtbuchholz commented May 12, 2023

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.

@ErrorTzy
Copy link

ErrorTzy commented Sep 2, 2023

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)

@dtbuchholz
Copy link

@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

@andreilgeorgescu
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants