mirror of
https://github.com/logseq/logseq.git
synced 2026-04-29 00:24:51 +00:00
Add keyboard shortcuts
Also, add macro support
This commit is contained in:
@@ -271,6 +271,18 @@
|
||||
prefix (if pre-heading? "" (str (apply str (repeat level pattern)) " "))]
|
||||
(str prefix (string/triml text))))
|
||||
|
||||
(defn macro-subs
|
||||
[macro-content arguments]
|
||||
(loop [s macro-content
|
||||
args arguments
|
||||
n 1]
|
||||
(if (seq args)
|
||||
(recur
|
||||
(string/replace s (str "$" n) (first args))
|
||||
(rest args)
|
||||
(inc n))
|
||||
s)))
|
||||
|
||||
(comment
|
||||
(defn sort-tasks
|
||||
[headings]
|
||||
|
||||
@@ -49,6 +49,20 @@
|
||||
[(keyword (string/lower-case k))
|
||||
v]))
|
||||
(into {}))
|
||||
macro-directives (filter (fn [x] (= :macro (first x))) directives)
|
||||
macros (if (seq macro-directives)
|
||||
(->>
|
||||
(map
|
||||
(fn [[_ v]]
|
||||
(let [[k v] (util/split-first " " v)]
|
||||
(mapv
|
||||
string/trim
|
||||
[k v])))
|
||||
macro-directives)
|
||||
(into {}))
|
||||
{})
|
||||
directives (->> (remove (fn [x] (= :macro (first x))) directives)
|
||||
(into {}))
|
||||
directives (if (seq directives)
|
||||
(let [directives (->
|
||||
(cond-> directives
|
||||
@@ -63,6 +77,7 @@
|
||||
(update :alias sep-by-quote-or-space)
|
||||
(update :tags sep-by-quote-or-space)))
|
||||
directives)
|
||||
directives (assoc directives :macros macros)
|
||||
other-ast (drop-while directive? ast)]
|
||||
(if (seq directives)
|
||||
(cons ["Directives" directives] other-ast)
|
||||
|
||||
Reference in New Issue
Block a user