fix: nested page properties extracting

pull/2003/head
Tienson Qin 2021-05-26 12:55:41 +08:00
parent 20626ef670
commit 43101c3c43
2 changed files with 10 additions and 5 deletions

View File

@ -93,10 +93,13 @@
(or (util/safe-re-find page-ref-re s)
(util/safe-re-find #"[\,||#]+" s)))
(let [result (->> (string/split s page-ref-re-2)
(map (fn [s] (if (string/ends-with? (string/trimr s) "]],")
(let [s (string/trimr s)]
(subs s 0 (dec (count s))))
s)))
(mapcat (fn [s] (if (string/includes? (string/trimr s) "]],")
(let [idx (string/index-of s "]],")]
[(subs s 0 idx)
"]]"
(subs s (+ idx 3))])
[s])))
(remove #(= % ""))
(mapcat (fn [s] (if (string/ends-with? s "]]")
[(subs s 0 (- (count s) 2))
"]]"]

View File

@ -28,6 +28,8 @@
[["year" "\"1000\""]] []
[["foo" "[[bar]] test"]] ["bar" "test"]
[["foo" "[[bar]] test [[baz]]"]] ["bar" "test" "baz"]
[["foo" "[[bar]] test [[baz]] [[nested [[baz]]]]"]] ["bar" "test" "baz" "nested [[baz]]"]))
[["foo" "[[bar]] test [[baz]] [[nested [[baz]]]]"]] ["bar" "test" "baz" "nested [[baz]]"]
[["foo" "#bar, #baz"]] ["bar" "baz"]
[["foo" "[[nested [[page]]]], test"]] ["nested [[page]]" "test"]))
#_(run-tests)