Convert plaintext citekey to "live" MS Word citation

  • edited May 20, 2020
    As a sidenote, I advocate using CSL libraries with pandoc instead of bibtex:
  • Is it possible to pass variables (like page numbers) to the Word doc? I am noticing that the following text in my document

    [@williams1973a, p. 38]

    Appears like this in Word:

    "Raymond Williams, The Country and the City (New York: Oxford University Press, 1973)."
  • Can you get me a copy of the Word file? The locator is already supposed to be in there.
  • Filed an issue on github, in case anyone else wants to follow along.
  • @emilianoeheyns Can this lua-filter possibly be round-trip? I tested it to work perfectly .md -> .docx. However, I am wondering if it is possible to convert live citations in word document to pandoc citation style [@bibtex-citationkey] in markdown.
  • This filter as it is cannot; it should be possible in principle but it's more complex than from md -> docx.
  • In the not-too-distant future, Zotero should be able to do this natively. We're adding citekey to CSL and Zotero will almost certainly include it in field updates and this can then simply be done as a citation style. Doesn't help you if you need it now, though.
  • Technically that's already possible, but wouldn't give you markdown.

    But writing a lua filter to do this would be more complicated than the filter that goes from md to docx, because citations are already clearly marked in the pandoc AST. Zotero citations are not, so I'd have to recognize and replace them by their (probably nested and/or distributed) shape in the AST, so if Zotero makes that superfluous, I'd rather not bother. What kind of time scale is not-too-distant? Asking for a friend.
  • citation-key will be included in CSL 1.0.2, which is currently open for comments. We hope to tag a release in the next few weeks.

    I think the best approach for going from Word to Markdown is to convert to a citekey style in Word, then use pandoc to convert to Markdown. That avoids the need to sniff through the Word file to find citations in a filter.
  • That works great for me -- I don't relish the thought of going pattern matching through the docx xml. But it being in the CSL standard is separate from it appearing in Zotero of course.
  • dstillman has signalled that Zotero is starting work on the field updates (with 4.x cut off from syncing, the necessary preconditions are in place), but I don't think there's any sense of an ETA yet.
  • In the mean time, the Citation Key: in Extra approach will work.
  • @atmindoc when reading docx files, pandoc doesn't add the Zotero citation marker data to the document AST, so filters cannot know Zotero citations are even present. A filter therefore can't do the reverse conversion.
  • I just want to chime in, that this is wonderful, huge thanks to the people involved!

    I have set this up with a Pandoc Droplet ( which makes the conversion from md→ docx w/live references a simple drag and drop for Mac users.

    I do wonder there is any news on the reverse solution (convert to a citekey style in Word → pandoc to md) since @adamsmith mentioned it in June?
  • Those people would be me, by and large.

    It should be possible to do the reverse without a special citation style. I'll think about it.
  • It would be to good to have the reverse solution. Is there any update on this?

    I used EndNote before, and they have this function in the word plugin that allows converting the live reference back to the plain text cite key. It works well with the md.
  • In the meantime, since 2020 writing tools like Zettlr and Typora now has support for adding pandoc parameters when exporting from md to Word. However, I can't figure out how to add the parameters for live citations. The parameters I used in the droplet script was:

    --lua-filter=/Users/[user dir]/Zotero/zotero.lua --metadata=zotero_scannable_cite:true

    For instance in Typora, adding these as "extra arguments" in the Settings > Export > Word does nothing. Has anyone tried this?
Sign In or Register to comment.