mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 19:36:35 +00:00
Move markdown property colons into a var
This commit is contained in:
committed by
Tienson Qin
parent
001e0d302d
commit
8be0deecd0
@@ -44,7 +44,7 @@
|
||||
[line]
|
||||
(boolean
|
||||
(and (string? line)
|
||||
(util/safe-re-find #"^\s?[^ ]+:: " line))))
|
||||
(re-find (re-pattern (str "^\\s?[^ ]+" gp-property/colons " ")) line))))
|
||||
|
||||
(defn front-matter-property?
|
||||
[line]
|
||||
@@ -93,9 +93,10 @@
|
||||
(defn get-markdown-property-keys
|
||||
[content]
|
||||
(let [content-lines (string/split-lines content)
|
||||
properties (filter #(re-matches #"^.+::\s*.+" %) content-lines)]
|
||||
properties (filter #(re-matches (re-pattern (str "^.+" gp-property/colons "\\s*.+")) %)
|
||||
content-lines)]
|
||||
(when (seq properties)
|
||||
(map #(->> (string/split % "::")
|
||||
(map #(->> (string/split % gp-property/colons)
|
||||
(remove string/blank?)
|
||||
first
|
||||
string/upper-case)
|
||||
@@ -165,7 +166,7 @@
|
||||
[format properties]
|
||||
(when (seq properties)
|
||||
(let [org? (= format :org)
|
||||
kv-format (if org? ":%s: %s" "%s:: %s")
|
||||
kv-format (if org? ":%s: %s" (str "%s" gp-property/colons " %s"))
|
||||
full-format (if org? ":PROPERTIES:\n%s\n:END:" "%s\n")
|
||||
properties-content (->> (map (fn [[k v]] (util/format kv-format (name k) v)) properties)
|
||||
(string/join "\n"))]
|
||||
@@ -202,7 +203,7 @@
|
||||
built-in-properties-area (map (fn [[k v]]
|
||||
(if org?
|
||||
(str ":" (name k) ": " v)
|
||||
(str (name k) ":: " v))) properties)
|
||||
(str (name k) gp-property/colons " " v))) properties)
|
||||
body (concat (if no-title? nil [title])
|
||||
(when org? [properties-start])
|
||||
built-in-properties-area
|
||||
@@ -276,7 +277,7 @@
|
||||
|
||||
(not org?)
|
||||
(let [exists? (atom false)
|
||||
sym (if front-matter? ": " ":: ")
|
||||
sym (if front-matter? ": " (str gp-property/colons " "))
|
||||
new-property-s (str key sym value)
|
||||
property-f (if front-matter? front-matter-property? simplified-property?)
|
||||
groups (partition-by property-f lines)
|
||||
@@ -344,7 +345,7 @@
|
||||
(remove-f (fn [line]
|
||||
(let [s (string/triml (string/lower-case line))]
|
||||
(or (string/starts-with? s (str ":" key ":"))
|
||||
(string/starts-with? s (str key ":: ")))))))]
|
||||
(string/starts-with? s (str key gp-property/colons " ")))))))]
|
||||
(string/join "\n" lines)))))))
|
||||
|
||||
(defn remove-id-property
|
||||
|
||||
@@ -86,14 +86,14 @@
|
||||
(case (state/get-preferred-format) ;; TODO fix me to block's format
|
||||
:org (thing-at-point ":" input "\n")
|
||||
(when-let [line (:raw-content (line-at-point input))]
|
||||
(let [key (first (string/split line "::"))
|
||||
(let [key (first (string/split line gp-property/colons))
|
||||
line-beginning-pos (cursor/line-beginning-pos input)
|
||||
pos-in-line (- (cursor/pos input) line-beginning-pos)]
|
||||
(when (<= 0 pos-in-line (+ (count key) (count "::")))
|
||||
{:full-content (str key "::")
|
||||
(when (<= 0 pos-in-line (+ (count key) (count gp-property/colons)))
|
||||
{:full-content (str key gp-property/colons)
|
||||
:raw-content key
|
||||
:start line-beginning-pos
|
||||
:end (+ line-beginning-pos (count (str key "::")))}))))]
|
||||
:end (+ line-beginning-pos (count (str key gp-property/colons)))}))))]
|
||||
(assoc property :type "property-key"))))
|
||||
|
||||
(defn get-list-item-indent&bullet [line]
|
||||
|
||||
Reference in New Issue
Block a user