Copying hooks with (author,date) from Zotero

Right now, if I create a hook link from Zotero and, say, paste that into Textedit, it creates an hyperlink pointing to the Zotero item showing the item title (title of the paper, book, etc.)

For instance, creating a hook with

Abbas, M., Lipiński, W. P., Nakashima, K. K., Huck, W. T. S., & Spruijt, E. (2021). A short peptide synthon for liquid–liquid phase separation. Nature Chemistry, 1–9. https://doi.org/10.1038/s41557-021-00788-x

and pasting the hook link leaves us with the text A short peptide synthon for liquid–liquid phase separation.

I think it could be quite useful to be able to paste in the (author,date) format — widely used both in humanities and various STEM fields.

Use case: inserting (author,date) references to Obsidian. Currently, I copy the (author,date) text with Zotero’s native shortcuts, paste that into Obsidian, then go on to copy the hook link and paste it “over” the text in Obsidian.

Found a solution ; this time without Hook, and using Zotero’s native translators.

Based on: GitHub - silentdot/zotero-markdown-translator: A simple Zotero translator that creates a Markdown Link when exporting
…that I modified to export markdown links as (author,date). Just place the file in Zotero’s translator folder and select the translator in the export setting (details in the link above).

This way, the “Copy citation” shortcut in Zotero (⌘⇧C) will copy a markdown link formatted as [(Author,Date)](zotero-link).

My modified version of the translator (Markdown.Item.URI.js):

{
	"translatorID":"8dbf9b92-f796-4153-8f2e-ac6c157500dc",
	"translatorType":2,
	"label":"Markdown Item URI",
	"creator":"Silent",
	"target":"markdown",
	"minVersion":"2.0",
	"maxVersion":"",
	"priority":200,
	"inRepository":false,
	"lastUpdated":"2020-11-30"
	}
	 
	
	function doExport() {
		var item;
		while(item = Zotero.nextItem()) {
			var date = Zotero.Utilities.strToDate(item.date).year;

			var year = date && !isNaN(date) ? " " + date : (typeof item.date == 'undefined'?  "" : " " + item.date);
			var library_id = item.libraryID ? item.libraryID : "";
			var author_lastname = getValidAuthor(item);
			var title = item.title ? "*" + item.title + "*" : "";
			var key = item.key;
	
			Zotero.write(`[(${author_lastname},${year})](zotero://select/items/${library_id}_${key})`);
		}
	}

	function getValidAuthor(item){
		if(item.creators && item.creators[0] && item.creators[0].lastName){
			return item.creators[0].lastName + "";
		}else{
			return "";
		}

	}
1 Like