Skip to content

Commit

Permalink
fixed link to path of images in Zotero
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanopagliari committed Jun 22, 2022
1 parent daf36c6 commit ec04483
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.

### Bugs
- Fixed bugs that prevented notes added in Zotero using markdown from being formatted properly
- Fixed code to manually select the folder where the images are located


## [0.9.10]
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "bibnotes",
"name": "BibNotes Formatter",
"version": "0.9.151",
"version": "0.9.152",
"minAppVersion": "0.12.0",
"description": "Plugin to import and format annotations from Zotero.",
"author": "Stefano Pagliari",
Expand Down
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.151",
"version": "0.9.152",
"description": "Plugin to export and format annotations from Zotero into Obsidian",
"main": "main.js",
"scripts": {
Expand Down
21 changes: 8 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,6 @@ export default class MyPlugin extends Plugin {
selectedLine = replaceTemplate(selectedLine, "&amp;", "&").replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');


console.log(selectedLine)

const lineElements: AnnotationElements = {
highlightText: "",
highlightColour: "",
Expand Down Expand Up @@ -560,7 +558,6 @@ export default class MyPlugin extends Plugin {
return noteElements;
}
parseAnnotationLinesintoElementsZotero(note: string) {

// clean the entire annotation
note = note
// .replace(
Expand All @@ -572,17 +569,16 @@ export default class MyPlugin extends Plugin {
// Correct when zotero exports wrong key (e.g. Author, date, p. p. pagenum)
.replace(/, p. p. /g, ", p. ")
.trim();

// Split the annotations into an array where each row is an entry
const lines = note.split(/<\/h1>|<\/p>|<h1>/gm);

const noteElements: AnnotationElements[] = [];

//Loop through the lines
const lengthLines = Object.keys(lines).length;
for (let indexLines = 1; indexLines < lengthLines; indexLines++) {


const selectedLineOriginal = unescape(lines[indexLines]);


//Remove HTML tags
let selectedLine = String(
Expand All @@ -594,8 +590,6 @@ export default class MyPlugin extends Plugin {
// // Correct encoding issues
selectedLine = replaceTemplate(selectedLine, "&amp;", "&");

console.log(selectedLine)

const lineElements: AnnotationElements = {
highlightText: "",
highlightColour: "",
Expand Down Expand Up @@ -1135,10 +1129,11 @@ export default class MyPlugin extends Plugin {
// Check if the user settings has approved the importing of images

pathImageOld = path.format({
dir: this.pathZoteroStorage + lineElements.imagePath,
dir: this.settings.zoteroStoragePathManual + lineElements.imagePath,
base: "image.png",
});

});

pathImageNew = path.normalize(
path.format({
dir: normalizePath(
Expand All @@ -1164,6 +1159,7 @@ export default class MyPlugin extends Plugin {
) {
//if the settings is to link to the image in the zotero folder
if (this.settings.imagesCopy === false) {

lineElements.rowEdited = "![](file://" + encodeURI(pathImageOld) + ")" + lineElements.zoteroBackLink;
}
//if the settings is to copy the image from Zotero to the Obsidian vault
Expand Down Expand Up @@ -2176,11 +2172,10 @@ export default class MyPlugin extends Plugin {
"{{UserNotes}}",
resultAnnotations.extractedUserNote
);




litnote = litnote.replace(
"{{Yellow}}",
"{{Yellow}}",
resultAnnotations.extractedAnnotationsYellow
);
litnote = litnote.replace(
Expand Down
2 changes: 1 addition & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ export class SettingTab extends PluginSettingTab {
);
new Setting(importImages)
.setName("Zotero Local Folder")
.setDesc(`Add the path on your computer where Zotero's data is stored (e.g. "/Users/yourusername/Zotero/storage"). This field is required only when this is different from the folder where the PDF files are stored. To retrieve this information, open Zotero --> Preferences --> Advanced --> Files and Folder, and copy the "data directory location"`)
.setDesc(`Add the path on your computer where Zotero's data is stored (e.g. "/Users/yourusername/Zotero/storage"). This field is required only when this is different from the folder where the PDF files are stored. To retrieve this information, open Zotero --> Preferences --> Advanced --> Files and Folder, and copy the "data directory location", followed by the subdirectory "/storage"`)
.addText((text) =>
text
.setValue(settings.zoteroStoragePathManual)
Expand Down

0 comments on commit ec04483

Please sign in to comment.