Use existing .docx (with citations) in a markdown app

Hello, I have recently started using Ulysses for writing and now I'd like to use it for my research. I have come across some useful tips and tools about using Ulysses with Zotero. The workflow is something like this: 1) write in Ulysses; 2) insert citations with BetterBibTex and the zot-pick script; 3) export into .docx with pandoc and citeproc.

I still have many of my drafts in MS-Word. I am trying to find a workaround for importing my MS-Word files into Ulysses Markdown BUT keeping the citations already typed in... I was thinking of probably transforming the already existing citations into the citation-keys brackets format that works in Markdown (v.g., [@authoryear]). But I am not sure about how to make this happen for all of my citations. The only thing that comes to my mind is to manually re-insert every citation-key in Ulysses. Does something come to your mind to achieve this workflow?

Josh
  • @emilianoeheyns Can the pandoc filter you wrote also go in the Word -> Markdown direction or only the reverse? Can you give a link?
  • It can't yet. But the first step would be to run it through something like the ODF scanner I think? Going by the description above, the source text is just manually-typed citations. Once the Zotero reference marks are in place, I can look at transforming those back to markdown citations.
  • @bwiernik thx. @emilianoeheyns could you please post a link to your script? curious to see how it works. Mine is an adaptation of the one available at https://raphaelkabo.com/blog/posts/markdown-to-word/
  • https://retorque.re/zotero-better-bibtex/exporting/pandoc/#from-markdown-to-zotero-live-citations. But it does something different than the setup from raphael kabo (even if his setup could in principle use my pandoc filter); raphael goes from markdown to word-with-bibliography. Mine goes from markdown to word-with-Zotero-citation markers; after processing, the document is "connected" to Zotero and you'd use Zotero to produce the bibliography, not pandoc. I guess the use-case for my filter is mainly that you want to switch from markdown to word (maybe because you need a Word facility like track changes or the equation editor).

    It is in principle possible to create a reverse filter that takes Zotero-citations in a word file and produce a markdown file with equivalent citation markers, it's just a lot harder, since in going from markdown -> word, pandoc marks the citations clearly and they're almost trivial to pick out and replace. Going the other way, not only are zotero-citations not clearly marked (as far as pandoc is concerned, it's just text), the important bits that make it recognizable (the zotero bookmark/fields the citations live in) do not make it into the AST. So I'd have to get chunks of text and inspect the raw XML and replace the proper bits of it and nothing else, keeping the XML structure intact, before the rest of the pandoc pipeline gets to it. I'm not even sure this is possible. I might have to resort to python, which is a shame, because that's harder for most users to install.
  • I wrote a small script that does exactly this:

    https://gist.github.com/alanzchen/6c30227d82f411da1baba4b7d1ec088b

    You will need to first save your word file: https://www.zotero.org/support/kb/moving_documents_between_word_processors

    Then use pandoc to convert it to markdown:

    `pandoc example.docx --wrap=none -o example.md`

    Finally use my script:

    `./convert.py /Users/alan/Zotero/better-bibtex-search.sqlite example.md`

    Feel free to try it out!
Sign In or Register to comment.