I guess it works like this: When you convert from md to docx (using the filter), Zotero BBT will use the citekey to create the fields in the docx file. Here, Zotero doesn’t use citation keys, but some internal id. (You can actually have a look by inspecting the field codes.) Then, when you go back to markdown, I think this is more an issue with how pandoc’s docx reader works.

 

Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Alex
Gesendet: Mittwoch, 8. November 2023 22:32
An: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Betreff: Re: Preserving citations between docx and markdown conversions

 

Thanks for your help Denis,

I think I'm starting to get a grasp on how this is working.

If I run my document through the zotero-better-bibtex filter, then the docx+citations reader. I get some markdown like this:

---
...
references:

...

  citation-key: Aigrain2021

...

  id: 476

---

#
Introduction

Here is a reference to one of the entries in my bibliography
[@476].

# References {#references .unnumbered}


It seems the zotero/better-bibtex filter is using an internal id (476) instead of the original citation key. I presume this is required for the integration between Zotero and Word.
I might try and dig in to the docx to markdown conversion to:

  1. Switch the ids of the citations back to the original citation key strings.
  2. Consider exporting the 'references' metadata as a separate .bib file instead of in the header.

On Wednesday, November 8, 2023 at 2:33:30 AM UTC+11 denis...-NSENcxR/0n0@public.gmane.org wrote:

Pandoc will resolve citations when converting to docx. Your « -t docx+citations » seems to have no effect here.

 

However, there exists a filter that might be useful here: https://retorque.re/zotero-better-bibtex/exporting/pandoc/index.html#from-markdown-to-zotero-live-citations

This will enable you to convert markdown citations to Zotero fields. Obviously, this means you’ll need to manage your references with Zotero.

Converting them back to Markdown citations should work out of the box since 2.18, see the changelog : https://pandoc.org/releases.html#pandoc-2.18-2022-04-04

Docx reader:

  • Enable citations extension for docx reader (#7840). When enabled, Zotero, Mendeley, and EndNote citations embedded in a docx are parsed as native pandoc citations. (When disabled, the generated citation text and bibliography are passed through as regular text.) The bibliography generated by the plugin is suppressed. Instead, bibliographic data embedded in citation items is added to the references metadata field so that it can be used with --citeproc.

So, here you’ll also see what the citations extension does for docx…

 

Best,

Denis

 

Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Alex
Gesendet: Dienstag, 7. November 2023 10:03
An: pandoc-discuss <pandoc-...@googlegroups.com>
Betreff: Preserving citations between docx and markdown conversions

 

Sie erhalten nicht oft eine E-Mail von ac.ri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org. Erfahren Sie, warum dies wichtig ist

Hello! I am investigating using pandoc for my academic writing. I intend to do the majority of the writing in markdown but will have others reviewing and giving feedback through word (docx), and would like a way to re-integrate the edits back to markdown while keeping the text as close as possible. (md -> docx -> md)

 

In my markdown I have citations using the [@citekey] format:

 

Here is a reference to one of the entries in my bibliography [@Aigrain2021].

 

I would like a way to preserve citations when converting between docx and md.

I've tried the following approach but just get plain text (in the markdown) where the citation was.

 

Here is a reference to one of the entries in my bibliography (Aigrain
2021).

 

I am not sure whether the citations are being lost in the md to docx step or the docx to md step. (I am not familiar with the how word even stores citations)

 

Is what I want to do supported?

I have the files:

main.md

main.bib

nature-conservation.csl

 

The command I'm using to convert to docx (md -> docx):

pandoc --citeproc \
--bibliography main.bib \
--csl nature-conservation.csl \
-t docx+citations -o main.docx \
-f markdown+citations main.md

 

The command I'm using to convert back to markdown:

pandoc -s --citeproc \
--bibliography main.bib \
--csl nature-conservation.csl \
-t markdown+citations -o main.md \
-f docx+citations main.docx

 

Any ideas would be much appreciated. Thanks!

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/eead1157-56fa-4259-a223-a365c852e0cbn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/c85d1876-2c1e-41cf-a735-15ca9a5be81en%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/GV0P278MB021150B44F8F2F6199A336F283AFA%40GV0P278MB0211.CHEP278.PROD.OUTLOOK.COM.