fix: page ref not working as linked ref in property value

Also, fixed page ref lowercased in property value. eg: authors::
[[Jeff Howard]] -> jeff howard

Zotero tags will be parsed too.
This commit is contained in:
Tienson Qin
2021-07-28 23:45:26 +08:00
parent 82456f2c85
commit 6abca45828
7 changed files with 36 additions and 12 deletions

View File

@@ -199,7 +199,8 @@
page-refs (->>
(map (fn [v]
(when (string? v)
(let [result (text/split-page-refs-without-brackets v {:un-brackets? false})]
(let [v (string/trim v)
result (text/split-page-refs-without-brackets v {:un-brackets? false})]
(if (coll? result)
(map text/page-ref-un-brackets! result)
[]))))
@@ -464,6 +465,19 @@
(uuid custom-id))))
(db/new-block-id)))
(defn get-page-refs-from-properties
[properties]
(let [page-refs (mapcat (fn [v] (cond
(coll? v)
v
(text/page-ref? v)
[(text/page-ref-un-brackets! v)]
:else
nil)) (vals properties))]
(map (fn [page] (page-name->map page true)) page-refs)))
(defn extract-blocks
[blocks content with-id? format]
(try
@@ -593,6 +607,8 @@
(utf8/length encoded-content))}
:body @pre-block-body
:properties @pre-block-properties
:properties-order (keys @pre-block-properties)
:refs (get-page-refs-from-properties @pre-block-properties)
:pre-block? true
:unordered true}
(block-keywordize)))