Skip to content

Commit

Permalink
Merge pull request #51 from omnivore-app/fix/failed-to-fetch
Browse files Browse the repository at this point in the history
fix/failed to fetch
  • Loading branch information
sywhb authored Sep 19, 2022
2 parents 8118c33 + ac6d534 commit c8bcc36
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
13 changes: 11 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getDateForPage } from 'logseq-dateutils'
import {
Article,
compareHighlightsInFile,
escapeQuotationMarks,
getHighlightLocation,
loadArticles,
markdownEscape,
Expand Down Expand Up @@ -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}")]]`
)
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,7 @@ export const markdownEscape = (text: string): string => {
return text
}
}

export const escapeQuotationMarks = (text: string): string => {
return text.replace(/"/g, '\\"')
}
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit c8bcc36

Please sign in to comment.