Skip to content

Commit

Permalink
fix: CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed May 14, 2021
1 parent b87da8a commit 6753601
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 212 deletions.
9 changes: 3 additions & 6 deletions src/main/frontend/format/block.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@
(let [k (name k)
v (string/trim v)
k (string/replace k " " "-")
k (string/replace k "_" "-")
k (string/lower-case k)
k (string/lower-case k)
v (cond
(= v "true")
true
Expand All @@ -197,14 +196,12 @@
v

:else
(let [v' v
;; built-in collections
comma? (contains? #{"tags" "alias"} k)]
(let [v' v]
(if (and k v'
(contains? config/markers k)
(util/safe-parse-int v'))
(util/safe-parse-int v')
(text/split-page-refs-without-brackets v' comma?))))]
(text/split-page-refs-without-brackets v' true))))]
[(keyword k) v])))))]
{:properties properties
:page-refs page-refs}))
Expand Down
3 changes: 1 addition & 2 deletions src/main/frontend/format/mldoc.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@
properties (->> (map first directive-ast)
(map (fn [[_ k v]]
(let [k (keyword (string/lower-case k))
comma? (contains? #{:tags :alias :roam_tags} k)
v (if (contains? #{:title :description :roam_tags} k)
v
(text/split-page-refs-without-brackets v comma?))]
(text/split-page-refs-without-brackets v true))]
[k v])))
(reverse)
(into {}))
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/modules/outliner/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
{:pre [(tree/satisfied-inode? start-node)
(tree/satisfied-inode? end-node)]}
(let [sibling? (= (tree/-get-parent-id start-node)
(tree/-get-parent-id end-node))]
(tree/-get-parent-id end-node))]
(when sibling?
(ds/auto-transact!
[txs-state (ds/new-outliner-txs-state)]
Expand Down
50 changes: 26 additions & 24 deletions src/main/frontend/text.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,45 @@
(remove string/blank?)
(map string/trim))))

(defn- not-matched-nested-pages
[s]
(and (string? s)
(> (count (re-seq #"\[\[" s))
(count (re-seq #"\]\]" s)))))

(defn- concat-nested-pages
[coll]
(loop [coll coll
result []]
(if (seq coll)
(let [item (first coll)]
(if (= item "]]")
(recur (rest coll)
(conj
(vec (butlast result))
(str (last result) item)))
(recur (rest coll) (conj result item))))
result)))
(first
(reduce (fn [[acc not-matched-s] s]
(cond
(and not-matched-s (= s "]]"))
[(conj acc (str not-matched-s s)) nil]

not-matched-s
[acc (str not-matched-s s)]

(not-matched-nested-pages s)
[acc s]

:else
[(conj acc s) not-matched-s])) [[] nil] coll)))

(defn split-page-refs-without-brackets
([s]
(split-page-refs-without-brackets s false))
(split-page-refs-without-brackets s true))
([s comma?]
(cond
(and (string? s)
;; Either a page ref, a tag or a comma separated collection
(or (re-find page-ref-re s)
(re-find (if comma? #"[\,|,|#]+" #"#") s)))
(let [result (->> (string/split s page-ref-re-2)
(remove string/blank?)
(map (fn [s] (if (string/ends-with? (string/trimr s) "]],")
(let [s (string/trimr s)]
(subs s 0 (dec (count s))))
s)))
concat-nested-pages
(remove string/blank?)
(mapcat (fn [s]
(if (page-ref? s)
[(page-ref-un-brackets! s)]
Expand Down Expand Up @@ -126,17 +139,6 @@
:else
(remove-level-space-aux! text (config/get-block-pattern format) space?))))

(defn append-newline-after-level-spaces
[text format]
(if-not (string/blank? text)
(let [pattern (util/format
"^[%s]+\\s?\n?"
(config/get-block-pattern format))
matched-text (re-find (re-pattern pattern) text)]
(if matched-text
(string/replace-first text matched-text (str (string/trimr matched-text) "\n"))
text))))

;; properties

(def built-in-properties
Expand Down
Loading

0 comments on commit 6753601

Please sign in to comment.