Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checks added so that Zotero standalone notes can be exported. #141

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions content/mdnotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,15 @@ function lowerCaseDashTitle(content) {
}

function getZoteroNotes(item) {
var noteIDs = item.getNotes();
var noteArray = [];
if (item.isRegularItem()) {
var noteIDs = item.getNotes();

if (noteIDs) {
for (let noteID of noteIDs) {
let note = Zotero.Items.get(noteID);
noteArray.push(note);
if (noteIDs) {
for (let noteID of noteIDs) {
let note = Zotero.Items.get(noteID);
noteArray.push(note);
}
}
}

Expand All @@ -304,20 +306,22 @@ function getPDFFileLink(attachment) {

function getZoteroAttachments(item) {
const linkStylePref = getPref("pdf_link_style");
let attachmentIDs = item.getAttachments();
var linksArray = [];
for (let id of attachmentIDs) {
let attachment = Zotero.Items.get(id);
if (attachment.attachmentContentType == "application/pdf") {
let link;
if (linkStylePref === "zotero") {
link = `[${attachment.getField("title")}](${getZoteroPDFLink(attachment)})`;
} else if (linkStylePref === "wiki") {
link = formatInternalLink(attachment.getField("title"), "wiki");
} else {
link = `[${attachment.getField("title")}](${getPDFFileLink(attachment)})`;
if (item.isRegularItem()) {
let attachmentIDs = item.getAttachments();
for (let id of attachmentIDs) {
let attachment = Zotero.Items.get(id);
if (attachment.attachmentContentType == "application/pdf") {
let link;
if (linkStylePref === "zotero") {
link = `[${attachment.getField("title")}](${getZoteroPDFLink(attachment)})`;
} else if (linkStylePref === "wiki") {
link = formatInternalLink(attachment.getField("title"), "wiki");
} else {
link = `[${attachment.getField("title")}](${getPDFFileLink(attachment)})`;
}
linksArray.push(link);
}
linksArray.push(link);
}
}
return linksArray;
Expand Down Expand Up @@ -464,10 +468,14 @@ function getZoteroNoteTitles(item) {
function getNCFileName(item, filePrefs) {
let fileName;
if (item.isNote()) {
let parentItem = Zotero.Items.get(item.parentItemID);
let parentTitle = getFileName(parentItem);
let noteTitle = item.getField("title");
fileName = `${parentTitle} - ${noteTitle}`;
if (item.parentItemID) {
let parentItem = Zotero.Items.get(item.parentItemID);
let parentTitle = getFileName(parentItem);
fileName = `${parentTitle} - ${noteTitle}`;
} else {
fileName = `${noteTitle}`;
}
} else {
fileName = getFileName(item);
}
Expand Down