mirror of
https://github.com/logseq/logseq.git
synced 2026-05-04 10:56:32 +00:00
fix set-priority on # heading
This commit is contained in:
@@ -1032,6 +1032,31 @@
|
||||
(str marker " ")))]
|
||||
new-content))
|
||||
|
||||
(defn add-or-update-priority
|
||||
[content format priority]
|
||||
(let [priority-pattern #"(\[#[ABC]\])?\s?"
|
||||
[re-pattern new-line-re-pattern]
|
||||
(if (= :org format)
|
||||
[#"\*+\s" #"\n\*+\s"]
|
||||
[#"#+\s" #"\n#+\s"])
|
||||
skip-hash-pos
|
||||
(if-let [matches (seq (re-pos new-line-re-pattern content))]
|
||||
(let [[start-pos content] (last matches)]
|
||||
(+ start-pos (count content)))
|
||||
(count (re-find re-pattern content)))
|
||||
skip-marker-pos
|
||||
(if-let [matches (seq (re-pos bare-marker-pattern (subs content skip-hash-pos)))]
|
||||
(let [[start-pos content] (last matches)]
|
||||
(+ start-pos (count content)))
|
||||
0)
|
||||
pos (+ skip-hash-pos skip-marker-pos)
|
||||
new-content
|
||||
(str (subs content 0 pos)
|
||||
(string/replace-first (subs content pos)
|
||||
priority-pattern
|
||||
(str priority " ")))]
|
||||
new-content))
|
||||
|
||||
(defn pp-str [x]
|
||||
(with-out-str (clojure.pprint/pprint x)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user