ZoteroQuickLook improvements

It would be great if the developers could consider these two issues with ZoteroQuickLook.

1) Issue with invalid filenames for notes

ZoteroQuickLook saves Zotero notes as temporary HTML files. There's currently an issue with invalid filenames for notes that have a problematic 'title' line. This can break the QuickLook command on a parent item with PDF attachments and a problematic child note.

To fix this, I replaced this line:
let title = item.getNoteTitle();
title = title.replace(/[\*|"<>\?:!]/g, '');
title = title.replace(/[\/\\]/g, '-');
title = title.trim();
title = (title==="") ? "note" : title;

This is working for me, but one should probably do better. Zotero is currently using this code to strip potentially invalid characters, see this discussion. One might also want to take care of cases when there are two notes with the same name.

There's also a potential follow-up issue with removing the temporary HTML files that have invalid filenames ('cleanOldNotes'). If I remember correctly, I noticed that ZoteroQuickLook created a temporary HTML file with an invalid filename that wasn't easily removed.

2) Enhancement: use primary attachment

It would be nice if ZoteroQuickLook could use the primary attachment as the first file argument for the viewer. One would need to use Zotero's item.getBestAttachment(). (See here for the original request.)

(I will not be able to attempt a PR in the near future.)
Sign In or Register to comment.