Skip to content

tabulon-ext/zotero-odf-scan-plugin

 
 

Repository files navigation

ODF/DOCX Scan for Zotero

ODF/DOCX Scan for Zotero is an add-on for the Zotero reference manager that lets you insert plain-text citation markers into any document and then convert them into active Zotero citations. This provides Zotero citation support for word processors without a dedicated Zotero plugin, such as Scrivener.

The add-on supports two citation marker formats:

  • Scannable Cite — drag-and-drop markers from the Zotero client
  • Pandoc citations[@citekey] syntax using Zotero's Citation Key field

Both ODF (.odt) and DOCX (.docx) files are supported. ODF conversion requires LibreOffice and the Zotero LibreOffice plugin, DOCX conversion requires Microsoft Word and the Zotero Word plugin.

For full documentation, see the project website.

Installation

Download the latest release (.xpi file). In Zotero, go to Tools → Plugins, click the gear icon, and select "Install Plugin From File...".

The add-on installs the Scannable Cite export translator and adds an ODF Scan option under Zotero's Tools menu.

Scannable Cite markers

Set the "Default Output Format" to "Scannable Cite" in the Export tab of the Zotero Preferences. You can then insert markers by dragging items from your Zotero library or by pressing Ctrl+Alt+C (Cmd+Shift+C on macOS) to copy and then pasting.

A marker has five pipe-separated fields:

{See | Smith, (2012) |p. 45 | for an example |zu:2433:WQVBH98K}
Field Content
1 Prefix (e.g. "See")
2 Readable cite (author, year) — for display only
3 Locator (e.g. "p. 45", "ch. 3")
4 Suffix (e.g. "for an example")
5 Item URI — do not modify

Use - before the author name to suppress the author in the rendered citation. Use *asterisks* for italics and **double** for bold in prefixes and suffixes.

Pandoc citations

The add-on can also convert pandoc-style citations to and from Zotero citations. Pandoc citations use the [@citekey] syntax, where the citekey corresponds to the item's Citation Key field in Zotero.

Converting your document

  1. Save your document as .odt (OpenDocument) or .docx (Word)
  2. In Zotero, open Tools → ODF Scan
  3. Select the conversion direction
  4. Choose your input file and output destination
  5. Click "Process Document"

For ODF files, open the converted document in LibreOffice, click "Set Document Preferences" in the Zotero toolbar, choose a citation style, and Zotero will format all citations. Use "Insert Bibliography" to add a bibliography.

The add-on can also convert active Zotero citations back to markers or pandoc syntax. This is useful if you want to switch from LibreOffice or Word to a different editor.

Support

Report issues on the GitHub issue tracker or ask questions in the Zotero forums.

Development

Building

The build requires bash (Git Bash on Windows is fine). Before building, install dependencies once:

npm install

Then build the XPI:

npm run build

This runs build.sh, which zips the plugin sources into an installable XPI file.

Releasing

Releases are created with the release.sh script, which requires the GitHub CLI (gh):

# Public release
./release.sh 2.1.0

# Draft release (for testing before publishing)
./release.sh 2.1.0 --draft

The script will:

  1. Update version in package.json, manifest.json, and CITATION.cff
  2. Update updates.json with the new version and download URL
  3. Build the XPI and calculate its SHA256 hash
  4. Commit, tag (v2.1.0), and push
  5. Create a GitHub release with the XPI attached

Version numbering follows semver: MAJOR.MINOR.PATCH (e.g. 2.1.02.1.1 for a bug fix, 2.2.0 for a new feature).

Tests

Tests use the Node.js built-in test runner (node:test) — no extra test dependencies needed.

# Run all tests (unit + integration)
npm test

# Unit tests only
npm run test:unit

# Integration tests only
npm run test:integration

# Lint + tests
npm run test:all

Unit tests (test/unit/)

Test file What it covers
escapeXml XML entity escaping (&&amp;, <&lt;, etc.)
generateCitationID Random 8-character alphanumeric ID generation
extractTextRuns Parsing <w:r><w:t> runs from Word XML paragraphs
rebuildParagraph Writing modified text runs back into paragraph XML
buildWordField Building Word field XML (fldChar begin/instrText/end)
parsePandocCitationGroup Parsing @citekey entries from pandoc bracket syntax
parsePandocLocator Splitting locators (p. 45) from suffixes (emphasis added)
labelToPandocLocator Mapping CSL labels to pandoc prefixes (pagep. )
getItemByURI Resolving all Zotero URI formats (zu:, http://zotero.org/, zotero://select/)

Integration tests (test/integration/)

Test file What it covers
citationsToMarkers Zotero Word fields → pipe-separated scannable cite markers
citationsToPandoc Zotero Word fields → pandoc [@citekey] syntax
pandocToMarkers Pandoc [@citekey] syntax → scannable cite markers
markersToPandoc Pipe-separated markers → pandoc [@citekey] syntax

Integration tests use XML fixtures in test/fixtures/ and a Zotero mock (test/helpers/zotero-mock.js) that simulates item lookup without a running Zotero instance.

About

RTF/ODF-Scan for Zotero add-on

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 91.9%
  • Shell 3.3%
  • Fluent 2.0%
  • HTML 1.7%
  • CSS 1.1%