Skip to content

Commit

Permalink
Fixed bug in citekey export
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanopagliari committed Jan 14, 2023
1 parent d13f755 commit 2c4efe0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bibnotes",
"version": "0.9.214",
"version": "0.9.215",
"description": "Plugin to export and format annotations from Zotero into Obsidian",
"main": "main.js",
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ export default class MyPlugin extends Plugin {

}

//Create citekey
selectedEntry.citeKey = selectedEntry.citationKey

//Fix itemType
if (selectedEntry.itemType == "journalArticle") { selectedEntry.itemType = "Journal Article" }
if (selectedEntry.itemType == "report") { selectedEntry.itemType = "Report" }
Expand Down Expand Up @@ -371,6 +374,7 @@ export default class MyPlugin extends Plugin {
// Create an array with all the fields
const entriesArray = Object.keys(selectedEntry);


//replace the single-value placeholders with the value of the field
note = replaceAllTemplates(entriesArray, note, selectedEntry);

Expand Down Expand Up @@ -1842,7 +1846,6 @@ export default class MyPlugin extends Plugin {
}

extractAnnotation(selectedEntry: Reference, noteTitleFull: string) {

let extractedAnnotations = "";
let extractedAnnotationsYellow = "";
let extractedAnnotationsRed = "";
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export interface Reference {
authorKeyFullName: string;
id: number;
citationKey: string;
citeKey: string;
year: string;
citationInLine: string;
citationInLineInitials: string;
Expand Down
9 changes: 7 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ export function replaceAllTemplates(
for (let z = 0; z < entriesArray.length; z++) {
// Identify the keyword to be replaced
const KW = entriesArray[z];
console.log(KW)
const KW_Brackets = "{{" + KW + "}}";
// replace the keyword in the template
console.log(KW_Brackets)
console.log(`${selectedEntry[KW as keyof Reference]}`)
copy = replaceTemplate(
copy,
KW_Brackets,
`${selectedEntry[KW as keyof Reference]}`
); // fixed the type
);
console.log(copy)
// fixed the type
}
return copy;
}
Expand Down Expand Up @@ -220,7 +225,7 @@ export const createAuthorKeyFullName = (creators: CreatorArray) => {
if (authorKey.length > 3) {
authorKeyFixed = authorKey[0] + " et al.";
}
console.log(authorKeyFixed)

if (authorKey.length > 0) { return authorKeyFixed }

//If there are no authors (because it is an edited book), then returns the name of the editors
Expand Down

0 comments on commit 2c4efe0

Please sign in to comment.