diff --git a/src/index.ts b/src/index.ts index 45d6db2..ee64332 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,6 +9,7 @@ import { getDateForPage } from 'logseq-dateutils' import { Article, compareHighlightsInFile, + escapeQuotationMarks, getHighlightLocation, loadArticles, markdownEscape, @@ -190,6 +191,10 @@ const fetchOmnivore = async (inBackground = false) => { :where [?b :block/page ?p] [?p :block/original-name "${pageName}"] + [?b :block/parent ?parent] + [?parent :block/uuid ?u] + [(str ?u) ?s] + [(= ?s "${targetBlock.uuid}")] [?b :block/content ?c] [(clojure.string/includes? ?c "${article.slug}")]]` ) @@ -213,7 +218,9 @@ const fetchOmnivore = async (inBackground = false) => { [(str ?u) ?s] [(= ?s "${existingBlock.uuid}")] [?b :block/content ?c] - [(= ?c "${highlight.content}")]]` + [(= ?c "${escapeQuotationMarks( + highlight.content + )}")]]` ) ).flat() if (existingHighlights.length > 0) { @@ -230,7 +237,9 @@ const fetchOmnivore = async (inBackground = false) => { [(str ?u) ?s] [(= ?s "${existingHighlight.uuid}")] [?b :block/content ?c] - [(= ?c "${noteChild.content}")]]` + [(= ?c "${escapeQuotationMarks( + noteChild.content + )}")]]` ) ).flat() if (existingNotes.length == 0) { diff --git a/src/util.ts b/src/util.ts index 97c1dc6..1dbf8c6 100644 --- a/src/util.ts +++ b/src/util.ts @@ -137,3 +137,7 @@ export const markdownEscape = (text: string): string => { return text } } + +export const escapeQuotationMarks = (text: string): string => { + return text.replace(/"/g, '\\"') +} diff --git a/yarn.lock b/yarn.lock index 2b88746..f8a6d7f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1210,11 +1210,6 @@ resolved "https://registry.yarnpkg.com/@types/diff-match-patch/-/diff-match-patch-1.0.32.tgz#d9c3b8c914aa8229485351db4865328337a3d09f" integrity sha512-bPYT5ECFiblzsVzyURaNhljBH2Gh1t9LowgUwciMrNAhFewLkHT2H0Mto07Y4/3KCOGZHRQll3CTtQZ0X11D/A== -"@types/escape-latex@^0.1.30": - version "0.1.30" - resolved "https://registry.yarnpkg.com/@types/escape-latex/-/escape-latex-0.1.30.tgz#574f71a2716febffeb64a60a16c3a8c4804340fa" - integrity sha512-HRKSkPNGJuevkoDr8uuTRYUM9YIjEE9X7e7fP0l7uK6r1LUvnTFmYI2TrdSrZPrAPyoBUaq7KPC4c05204x0qQ== - "@types/json-schema@^7.0.9": version "7.0.11" resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz" @@ -2132,11 +2127,6 @@ escalade@^3.1.1: resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz" integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== -escape-latex@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/escape-latex/-/escape-latex-1.2.0.tgz#07c03818cf7dac250cce517f4fda1b001ef2bca1" - integrity sha512-nV5aVWW1K0wEiUIEdZ4erkGGH8mDxGyxSeqPzRNtWP7ataw+/olFObw7hujFWlVjNsaDFw5VZ5NzVSIqRgfTiw== - escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz"