mirror of https://github.com/status-im/reagent.git
Syntaxify comments
This commit is contained in:
parent
2c093bf47c
commit
f9e0dfe4b3
|
@ -7,6 +7,7 @@
|
|||
(def time-color (atom "#f34"))
|
||||
|
||||
(defn update-time [time]
|
||||
;; Update the time every 1/10 second to be accurate...
|
||||
(js/setTimeout #(reset! time (js/Date.)) 100))
|
||||
|
||||
(defn greeting [props]
|
||||
|
|
|
@ -83,9 +83,9 @@
|
|||
[:section#todoapp
|
||||
[:header#header
|
||||
[:h1 "todos"]
|
||||
[todo-input {:id "new-todo"
|
||||
:placeholder "What needs to be done?"
|
||||
:on-save add-todo}]]
|
||||
[todo-input-basic {:id "new-todo"
|
||||
:placeholder "What needs to be done?"
|
||||
:on-save add-todo}]]
|
||||
[:section#main
|
||||
[:input#toggle-all {:type "checkbox" :checked (zero? active)
|
||||
:on-change #(complete-all (pos? active))}]
|
||||
|
|
|
@ -9,19 +9,21 @@
|
|||
(let [ws " \\t\\n"
|
||||
open "[({"
|
||||
close ")\\]}"
|
||||
str-p "\"[^\"]*\""
|
||||
sep (str ws open close)
|
||||
comment-p ";.*"
|
||||
str-p "\"[^\"]*\""
|
||||
open-p (str "[" open "]")
|
||||
close-p (str "[" close "]")
|
||||
iden-p (str "[^" sep "]+")
|
||||
any-p (str "[" ws "]+" "|.")
|
||||
patt (re-pattern (str "("
|
||||
(string/join ")|(" [str-p open-p close-p
|
||||
iden-p any-p])
|
||||
(string/join ")|(" [comment-p str-p open-p
|
||||
close-p iden-p any-p])
|
||||
")"))
|
||||
keyw-re #"^:"]
|
||||
(for [[s str-litt open close iden any] (re-seq patt src)]
|
||||
(for [[s comment str-litt open close iden any] (re-seq patt src)]
|
||||
(cond
|
||||
comment [:comment s]
|
||||
str-litt [:str-litt s]
|
||||
open [:open s]
|
||||
close [:close s]
|
||||
|
@ -47,6 +49,8 @@
|
|||
:close (dec level)
|
||||
level)
|
||||
style (case kind
|
||||
:comment {:style {:color "gray"
|
||||
:font-style "italic"}}
|
||||
:str-litt {:style {:color "green"}}
|
||||
:keyw {:style {:color "blue"}}
|
||||
:builtin {:style {:font-weight "bold"
|
||||
|
|
Loading…
Reference in New Issue