mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 22:22:43 -05:00
Add token finding function
This commit is contained in:
parent
598e4d36fc
commit
59780a9d4d
1 changed files with 12 additions and 0 deletions
|
@ -23,6 +23,18 @@
|
||||||
|
|
||||||
;; Functions -------------------------------------------------------------------
|
;; 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]
|
(defn token-self-reference? [token-name reference-string]
|
||||||
(let [escaped-name (str/replace token-name "." "\\.")
|
(let [escaped-name (str/replace token-name "." "\\.")
|
||||||
regex (-> (str "{" escaped-name "}")
|
regex (-> (str "{" escaped-name "}")
|
||||||
|
|
Loading…
Add table
Reference in a new issue