lierdakil / pandoc-crossref

Pandoc filter for cross-references
https://lierdakil.github.io/pandoc-crossref/
GNU General Public License v2.0
911 stars 72 forks source link

Org-mode references no longer work #357

Open JonathanReeve opened 1 year ago

JonathanReeve commented 1 year ago

With this input:

#+LABEL: fig:postImpressions2
#+CAPTION: "Post-Impressions of the Post-Impressionists"
[[../03-colors/images/post-impressions.jpg]]

Check out [@fig:postImpressions2]

[@Fig:postImpressions2] is capitalized.

Running pandoc figures2.org --filter pandoc-crossref gives:

<figure>
<img src="../03-colors/images/post-impressions.jpg"
id="fig:postImpressions2"
alt="Figure 1: &quot;Post-Impressions of the Post-Impressionists&quot;" />
<figcaption aria-hidden="true">Figure 1: "Post-Impressions of the
Post-Impressionists"</figcaption>
</figure>
<p>Check out [@fig:postImpressions2]</p>
<p>[@Fig:postImpressions2] is capitalized.</p>

In other words, pandoc-crossref correctly numbers the figure, and assigns a caption, but the references are no longer converted to "fig. 1" and "Fig. 1," respectively.

I suppose the larger issue is that there's no documentation for org-mode input. I'll open a separate issue for that.

JonathanReeve commented 1 year ago

Some version information:

pandoc 2.17.1.1
Compiled with pandoc-types 1.22.2, texmath 0.12.4, skylighting 0.12.3.1,
citeproc 0.6.0.1, ipynb 0.2
User data directory: /home/jon/.local/share/pandoc
Copyright (C) 2006-2022 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
pandoc-crossref v0.3.13.0 git commit UNKNOWN (UNKNOWN) built with Pandoc v2.17.1.1, pandoc-types v1.22.2 and GHC 9.0.2
JonathanReeve commented 1 year ago

So it looks like since pandoc moved to the org-cite syntax, the "Berkeley-style" citations like [@someReferenceHere] are no longer parsed as citations:

jon@jon-laptop ~/D/C/D/test (master)> echo "[@citation]" | pandoc -f org -t native
[ Para [ Str "[@citation]" ] ]
jon@jon-laptop ~/D/C/D/test (master)> echo "[cite:@citation]" | pandoc -f org -t native
[ Para
    [ Cite
        [ Citation
            { citationId = "citation"
            , citationPrefix = []
            , citationSuffix = []
            , citationMode = NormalCitation
            , citationNoteNum = 0
            , citationHash = 0
            }
        ]
        [ Str "[cite:@citation]" ]
    ]
]

And looking through pandoc-citeproc's code, it looks like it assumes references are first being parsed as citations.

So a workaround to this is just to prepend cite: to references:

#+title: Figures

#+NAME: postImpressions2
#+LABEL: fig:postImpressions2
#+CAPTION: "Post-Impressions of the Post-Impressionists"
[[../03-colors/images/post-impressions.jpg]]

Or check out [cite:@fig:postImpressions2].

[cite:@Fig:postImpressions2] is capitalized.

Which behaves as expected.