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

Fix broken getCiteKey() resulting from recent BBT update #225

Open
wants to merge 1 commit into
base: master
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
19 changes: 9 additions & 10 deletions content/mdnotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,11 @@ function getDateAdded(item) {
return simpleISODate(date)
}
function getCiteKey(item) {
if (typeof Zotero.BetterBibTeX === "object" && Zotero.BetterBibTeX !== null) {
var bbtItem = Zotero.BetterBibTeX.KeyManager.get(item.getField("id"));
return bbtItem.citekey;
}

return "undefined";
try {
return item.getField('citationKey');
} catch (_) {
return undefined;
}
}

function getLocalZoteroLink(item) {
Expand Down Expand Up @@ -523,7 +522,7 @@ function replace_wildcards(str, args) {


/**
*
*
* @param {string} str The string to be replaced
* @param {Object} args An array with the placeholder name as key and the (formatted) contents as values
* @returns {string} A string with the placeholders replaced
Expand Down Expand Up @@ -728,7 +727,7 @@ async function getZoteroNoteFileContents(item) {
let fileContents = remove_invalid_placeholders(
replace_placeholders(template, formattedPlaceholders)
);

fileContents = replace_wildcards(fileContents, note);
return { content: fileContents, name: fileName };
}
Expand Down Expand Up @@ -953,10 +952,10 @@ Zotero.Mdnotes =
async getRegularItemContents(item) {
let metadata = getItemMetadata(item);
let template = await readTemplate("Zotero Metadata Template");

// Add custom placeholders
get_placeholder_contents(template, metadata);

// Add formatting
let formattedPlaceholders = format_placeholders(metadata);
let newContents = remove_invalid_placeholders(
Expand Down