Help: From Markdown to Zotero live citations

Hi I am new on the forum but have been using Zotero for a few years now with the word plug-in. I want to change my workflow to write everything in Obsidian with pandoc references. Then convert the md file to a word document with live Zotero citations for editing. So @emilianoeheyns solution seems like the best one:

But I am a complete noob to pandoc and working with md files so I could use some help.
This is the command I tried to run:
pandoc /Users/aleks/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Notes/Zotero/ -s -o --lua-filter=/Users/aleks/Google Drive/Study/Archive/Better\ BibLaTex/zotero.lua --metadata=zotero_scannable_cite:true --metadata=zotero_client:jurism /Users/aleks/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Notes/Zotero/TestFile.docx

where I get:
[WARNING] Could not deduce format from file extension
Defaulting to html
pandoc: Drive/Study/Archive/Better BibLaTex/zotero.lua: openBinaryFile: does not exist (No such file or directory)

Could anyone please help?

Here are the directories:
Biblatex file:
/Users/aleks/Google\ Drive/Study/Archive/Better\ BibLaTex/My\ Library.bib

Pandoc filter:
/Users/aleks/Google\ Drive/Study/Archive/Better\ BibLaTex/zotero.lua

/Users/aleks/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Notes/Zotero/

Output (where I want a new docx file to go):
/Users/aleks/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Notes/Zotero/TestFile.docx

Content of the test md file:
This was an amazing idea [@levyContraPolitanism2020, pp.45]
In the beginnging was the deed [@hallBernardWilliamsBasic2015, pp. 24-25]
What do you usually do on your day off? [@rossiBeingRealisticDemanding2019, 45]

Thanks in advance!
  • You at least have not escaped all spaces in the lua filter path (I'd recommend using quotes, much more readable), and you use "-o" but do not follow it with the file to output.
  • Hey! Thanks for the reply. Sorry for the basic mistakes. I rewrote the line:
    pandoc --lua-filter="/Users/aleks/Google Drive/Study/Archive/Better BibLaTex/zotero.lua" --metadata=zotero_scannable_cite:true --metadata=zotero_client:jurism "/Users/aleks/Library/Mobile Documents/iCloud~md~obsidian/Documents/Notes/Zotero/" -s -o "/Users/aleks/Desktop/TestFile.docx" --to docx --standalone

    And now get a different error:
    zotero-live-citations a266bf0e6
    Error running filter /Users/aleks/Google Drive/Study/Archive/Better BibLaTex/zotero.lua:
    PandocHttpError ",hallBernardWilliamsBasic2015,levyContraPolitanism2020" (HttpExceptionRequest Request {
    host = ""
    port = 24119
    secure = False
    requestHeaders = []
    path = "/better-bibtex/export/item"
    queryString = "?pandocFilterData=true&translator=json&citationKeys=rossiBeingRealisticDemanding2019%2ChallBernardWilliamsBasic2015%2ClevyContraPolitanism2020"
    method = "GET"
    proxy = Nothing
    rawBody = False
    redirectCount = 10
    responseTimeout = ResponseTimeoutDefault
    requestVersion = HTTP/1.1
    (ConnectionFailure Network.Socket.connect: : does not exist (Connection refused)))
    stack traceback:
    [C]: in function 'pandoc.mediabag.fetch'
    ...ks/Google Drive/Study/Archive/Better BibLaTex/zotero.lua:1732: in upvalue 'load_items'
    ...ks/Google Drive/Study/Archive/Better BibLaTex/zotero.lua:1742: in function 'zotero.get'
    ...ks/Google Drive/Study/Archive/Better BibLaTex/zotero.lua:1895: in function <...ks/Google Drive/Study/Archive/Better BibLaTex/zotero.lua:1878>
    (...tail calls...)

    Any more tips would be greatly appreciated :)
  • Is zotero running when you run this?
  • Sorry, that should have been: is Juris-M running while you run this?
  • It worked! Thank you :)

    Separately, is there a way to get rid of the grey square field brackets that appear in word after conversion?
  • Someone who uses Word will have to help with that.
  • Can you show a screenshot of what you mean? (Upload somewhere and link here)
  • edited May 11, 2022

    @aleksmaster thanks for your comments and @emilianoeheyns thanks to you too. This page was the final piece of the puzzle and I'm super excited that I got md to word with scannable citations to work!! woop :)


    As another "noob", I have got this working but had to piece together lots of different pieces of information. I think this took me 2 full days to figure out?, and I would have appreciated a lot more of the basic information. I've added a lot of this basic information for the next person who gets stuck!

    This code worked fine for me, more details below:

    pandoc --lua-filter=zotero.lua -s -o success.docx

    To get there I needed to:

    1. Download and install pandoc
    1a. read their getting started guide:

    2. For a simpler code, all files need to be in the same folder. Mine was documents/pandoc-test

    3. Download the "Pandoc Filter" mentioned here: .
    3a. Note to do this, right click download linked file. Save this file in the folder you created in step 2. It will be called zotero.lua

    4. Sort out Zotero, maybe someone can comment on which bits are necessary in a,b,c. You need the betterbibtex add on. Downloadable from here:
    4a. Zotero Preferences: export -- quick copy -- item format -- Better BibTeX Quick Copy: [@citekeys]
    4b. Zotero Preferences: Better BibTex -- Export -- Quick-Copy -- Format -- Pandoc citation and checked the box surround Pandoc citations with brackets
    4c. Zotero Preferences: Better BibTeX -- Citation Keys -- format [authors1]_[year] (I think this step is unnecessary)
    4d. Export Zotero Library. (Exit out of preferences) Right click My Library (or whatever your main library is called) -- Export Library -- Format Better CSL YAML.
    4e. Save this to the same folder mentioned in step 2. Mine is called MyLibrary.yaml

    5. Create a markdown file with citations (save in folder created in step 2). Mine was called
    5a. The citations can be copied from zotero using quick copy (cmd shift c) and pasted in your markdown file. When pasted they will look something like this: [@SandhuEtAl_2021]
    5b. I had no need for the meta data mentioned here: Though I'm sure that when you understand more, this is helpful.

    6. Your folder created in step two now has three files. MyLibrary.yaml | | zotero.lua

    7. choose a name for the document you want to create - I called mine success.docx

    8. Open Terminal to use Pandoc. Type each command below and push enter.
    8a. To set the location of your files - type in terminal: cw documents/pandoc-test
    8b. To check you've set the right location - type in terminal: pwd
    8c. To run the pandoc file conversion - type in terminal: pandoc --lua-filter=zotero.lua -s -o success.docx

    From what I understand, the terminal command means:

    pandoc = use the pandoc program

    --lua-filter=zotero.lua = check out this code. Also known as a filter. (None of which I understand). = take this markdown file

    -s = create a “standalone” file

    -o success.docx : output a new file called success.docx

    The below also work, and I assume are useful if you understand more.

    pandoc --lua-filter=zotero.lua --metadata=zotero_client:zotero -s -o success.docx

    pandoc --lua-filter=zotero.lua --metadata=zotero_scannable_cite:true --metadata=zotero_client:zotero -s -o success.docx

    Outputted Word Doc:

    The ugly grey square field brackets that appear in word after conversion seem to be bookmarks and can be removed. You need to use Visual Basic to do so.

    Things I didn't need to do:
    - to use homebrew
    - to understand what PATH meant
    - to understand what a filter was
    - to have some sort of LaTeX installed
    - to have metadata at the top of my .md file
    - to use or understand Juris M
    - to read pandoc advanced user guide for citations

    Note: I'm doing this in the most basic way and I'm sure all these other things are helpful when you know what you're doing. But they led me down confusing reading paths.
Sign In or Register to comment.