Page reference format changed to square brackets

This commit is contained in:
Tienson Qin
2020-05-01 12:17:41 +08:00
parent 60a8b29cd6
commit 1fbe78f923
3 changed files with 53 additions and 39 deletions

View File

@@ -9,11 +9,14 @@
(vector? block)
(= "Heading" (first block))))
(defn target-block?
(defn page-reference-block?
[block]
(and
(vector? block)
(contains? #{"Target" "Radio_Target"} (first block))))
(= "Link" (first block))
(= "Search" (first (:url (second block))))
(not (contains? #{\# \*} (first (second (:url (second block))))))
))
(defn task-block?
[block]
@@ -64,8 +67,9 @@
(let [ref-pages (atom [])]
(walk/postwalk
(fn [form]
(when (target-block? form)
(swap! ref-pages conj (string/capitalize (last form))))
(when (page-reference-block? form)
(let [page (second (:url (second form)))]
(swap! ref-pages conj (string/capitalize page))))
form)
(concat title children))
(assoc heading :ref-pages (vec @ref-pages))))