Skip to content

masaki39/simple-citations

Repository files navigation

Simple Citations

GitHub Release Total Downloads

This is an Obsidian plugin that reinforces the workflow between Zotero and Obsidian. It enables the importation of literature notes from Zotero, and use them not only as the knowledge base but also the references for your writing. Requiring the installation of Better Bibtex for Zotero and Pandoc.

✨ Features

Add & update literature notes from the bibliography file in one go

command: Add literature note

demo

The dataview query in the gif above is as follows:

table without id 
authors[0] as FirstAuthor, journal, year, title, 
link(file.name, "Note") as Note,
elink(zotero,"Zotero") as Zotero,
elink(doi,"DOI") as DOI
from "Literatures" // set the folder name of the literature notes
sort file.ctime desc
limit 100

And the notes generated by the command is as follows:

Important

You have options to add literature notes automatically when the bibliography file is updated. You also have options to automatically update literature notes when opened.

This means that you have to add items only to Zotero, and automatically add/update them to Obsidian.

Using literature notes as the references and export to docx(requires pandoc)

command: Pandoc Citeproc Execution (docx)

demo

  • Optionally, set csl file path or url in the properties named csl.
  • CSL file is the file that defines the citation style of the journal.
  • You can download or get url of the csl file from here.

The result file(docx) is as follows:

⚙️ Initial Settings

  1. Install the better bibtex for zotero to the Zotero and configure the export of the bibliography file.
    • Set the export location to your vault.
    • Set the automatic export option to true.
    • Set the file type to Better CSL JSON.
  2. Enable the Obsidian community plugin, then install Simple Citations and activate it.
  3. Set the bibliography file path and export folder path in the plugin settings.
  4. You can use the commands:
    • Add literature note
    • Update literature note
    • Update literature note (active file)
    • Pandoc Citeproc Execution (docx)
    • Copy missing note links
      • This command identifies and copies links to literature notes that are not included in the JSON file.

Warning

Citekeys containing # ^ [ ] | \ / : will be skipped as these characters are not allowed in Obsidian filenames. Check the console log if items are missing.

➕ Additional options

Tip

The optional content below will be removed if you set the option to false and execute the "Update" command.

🏷️ Tag Option

Generate tags for the following:

  • author/${firstAuthor}
  • journal/${journalName}

🧩 Optional fields

Better Bibtex for Zotero has the function to add optional fields to the bibliography file.

  1. Open the Zotero
  2. Open the "Preferences"
  3. Set "postscript" as you want

Reference for the script. → Scripting :: Better BibTeX for Zotero

Postscript examples

Zotero itemkey
if (Translator.BetterCSLJSON) {
  csl.key = zotero.key;
}

Set key in the plugin settings.

PDF file path
if (Translator.BetterCSLJSON) {
  csl.pdf = zotero.attachments
    .filter(a => a.localPath && a.localPath.toLowerCase().endsWith('.pdf'))
    .map(a => a.localPath);
}

Set pdf in the plugin settings.

Collection name
if (Translator.BetterCSLJSON) {

  function path(key) {
    const coll = Translator.collections[key]
    if (!coll) return ''
    if (!coll.parent) {return `${coll.name}`}
    else {return `${path(coll.parent)}/${coll.name}`}
  }

  let collections = [];

  zotero.collections.forEach((key) => {
    collections.push(path(key))
  });

  csl.collections = collections;
}

Set collections in the plugin settings.

From Issues #5

📝 Abstract Option

Insert the abstract section in the top of the note. The comment tag below is used to identify the abstract section.

<!-- START_ABSTRACT -->

<!-- END_ABSTRACT -->

📄 Template Option

Insert the template content in the top of the note. The comment tag below is used to identify the template section.

<!-- START_TEMPLATE -->

<!-- END_TEMPLATE -->

Note

This template is applied to all notes and the content is static. Therefore, it is recommended to use Dataview for setting dynamic templates.

🔗 Link Formatting

When executing the "Pandoc Citeproc Execution (docx)" command, the link format is temporarily converted to the format of the pandoc citeproc.

The plugin modifies the link format as follows:

  • [[@citation-key]][@citation-key]
  • [[@citation-key|aliases]][@citation-key] // aliases are allowed
  • [[@citation-key]][[@citation-key]][@citation-key;@citation-key] // multiple citations are allowed
  • [[@citation-key]] [[@citation-key]][@citation-key;@citation-key] // spaces or line breaks can be inserted between links
  • End of a sentence: [[@citation-key]] → end of a sentence [@citation-key]. // inserts links before . if there is nothing between them.

🙏 Support

Buy Me a Coffee at ko-fi.com

About

Add & update simple literature notes from Zotero.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 21