0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 06:02:32 -05:00

Add token finding function

This commit is contained in:
Florian Schroedl 2024-06-21 19:40:03 +02:00
parent 598e4d36fc
commit 59780a9d4d

View file

@ -23,6 +23,18 @@
;; Functions -------------------------------------------------------------------
(defn find-token-references
"Finds token reference values in `str` and returns a set with all contained namespaces."
[str]
(some->> (re-seq #"\{([^}]*)\}" str)
(map second)
(into #{})))
(comment
(find-token-references "{foo} + {bar}")
(find-token-references "nothing")
nil)
(defn token-self-reference? [token-name reference-string]
(let [escaped-name (str/replace token-name "." "\\.")
regex (-> (str "{" escaped-name "}")