From b9d25742854f41b829dfc36f4ca4eca6e96bca78 Mon Sep 17 00:00:00 2001 From: Aaron Gascoigne Date: Tue, 29 Oct 2024 01:20:34 -0400 Subject: [PATCH 1/3] Optimize calling order of readwise sync note Do all the operations that use the highlight note before generating the sync log. --- aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseNotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseNotes.js b/aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseNotes.js index 134836443..944e47a31 100644 --- a/aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseNotes.js +++ b/aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseNotes.js @@ -56,8 +56,8 @@ export async function parseHighlightsAndWriteToNote(highlightSource: any): Promi } } if (outputNote) { - await writeReadwiseSyncLogLine(noteTitle, highlightSource.highlights.length) await highlightSource.highlights.map((highlight) => appendHighlightToNote(outputNote, highlight, highlightSource.source, highlightSource.asin)) + await writeReadwiseSyncLogLine(noteTitle, highlightSource.highlights.length) } } catch (error) { logError(pluginJson, error) From 17b8bb514008b3ee6bfe627a5fd59d0508c5a702 Mon Sep 17 00:00:00 2001 From: Aaron Gascoigne Date: Tue, 29 Oct 2024 01:22:44 -0400 Subject: [PATCH 2/3] Fix formating by replacing spaces and '&' --- .../src/NPReadwiseHelpers.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseHelpers.js b/aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseHelpers.js index 7de50a6b0..944d728e6 100644 --- a/aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseHelpers.js +++ b/aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseHelpers.js @@ -96,12 +96,9 @@ export function buildReadwiseMetadataHeading(source: any): string { */ function formatTag(tag: string): string { const prefix = DataStore.settings.tagPrefix ?? '' - if (prefix === '') { - return `#${tag}` - } else { - return `#${prefix}/${tag}` - } -} + return `#${prefix ? `${prefix}/` : ''}${tag}` + .replace(/ /g, '_') + .replace(/&/g, 'and')} /** * Remove all newline characters from a string From 6e421dce97efaaf2b5616e38872a17cb01d31a7f Mon Sep 17 00:00:00 2001 From: Aaron Gascoigne Date: Tue, 29 Oct 2024 10:17:48 -0400 Subject: [PATCH 3/3] Readwise 1.1.5 fix formating of tags --- aaronpoweruser.ReadwiseUnofficial/CHANGELOG.md | 4 ++++ aaronpoweruser.ReadwiseUnofficial/plugin.json | 4 ++-- aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseNotes.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/aaronpoweruser.ReadwiseUnofficial/CHANGELOG.md b/aaronpoweruser.ReadwiseUnofficial/CHANGELOG.md index 5f808015b..47b4a7346 100644 --- a/aaronpoweruser.ReadwiseUnofficial/CHANGELOG.md +++ b/aaronpoweruser.ReadwiseUnofficial/CHANGELOG.md @@ -4,6 +4,10 @@ See Plugin [README](https://github.com/NotePlan/plugins/blob/main/aaronpoweruser.ReadwiseUnofficial/README.md) for details on available commands and use case. +## [1.1.5] Readwise 2024-10-28 (@aaronpoweruser) + +- Fix formatting of Readwise tags containing spaces or '&' characters. + ## [1.1.4] Readwise 2024-05-28 (@aaronpoweruser) - Add a setting for paragraph type. diff --git a/aaronpoweruser.ReadwiseUnofficial/plugin.json b/aaronpoweruser.ReadwiseUnofficial/plugin.json index 2371093fe..bce908137 100644 --- a/aaronpoweruser.ReadwiseUnofficial/plugin.json +++ b/aaronpoweruser.ReadwiseUnofficial/plugin.json @@ -4,8 +4,8 @@ "noteplan.minAppVersion": "3.4.0", "plugin.id": "aaronpoweruser.ReadwiseUnofficial", "plugin.name": "📚 Readwise Unofficial", - "plugin.version": "1.1.4", - "plugin.lastUpdateInfo": "Added paragraph type setting. Fixed links to highlights on web.\nFix sync log dates being wrong.\nAdd a sync log note. \nAdd support for daily reviews via templates", + "plugin.version": "1.1.5", + "plugin.lastUpdateInfo": "fix formatting of tags containing spaces.\nAdded paragraph type setting. Fixed links to highlights on web.\nFix sync log dates being wrong.\nAdd a sync log note. \nAdd support for daily reviews via templates", "plugin.description": "A sync plugin for Readwise", "plugin.author": "aaronpoweruser", "plugin.dependencies": [], diff --git a/aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseNotes.js b/aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseNotes.js index 944e47a31..29a841e62 100644 --- a/aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseNotes.js +++ b/aaronpoweruser.ReadwiseUnofficial/src/NPReadwiseNotes.js @@ -77,7 +77,7 @@ function appendHighlightToNote(outputNote: TNote, highlight: any, category: stri if (highlight.tags !== null && highlight.tags !== '') { for (const tag of highlight.tags) { - if (tag.name !== null && tag.name !== '' && tag.name.toLowerCase().startsWith('h') && tag.name.length === 2) { + if (tag.name !== null && tag.name !== '' && tag.name.toLowerCase().startsWith('h') && tag.name.trim().length === 2) { const headingLevel = parseInt(tag.name.substring(1)) + 1 if (headingLevel <= 8) { outputNote.insertHeading(removeNewlines(highlight.text), findEndOfActivePartOfNote(outputNote) + 1, headingLevel)