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:
parent
598e4d36fc
commit
59780a9d4d
1 changed files with 12 additions and 0 deletions
|
@ -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 "}")
|
||||
|
|
Loading…
Add table
Reference in a new issue