Is there any way to try to make girouette a drop-in replacement for tailwind?
What I mean is, I'd like be able to write {:class (css ["inline-block" "underline"])}
like {:class '[inline-block underline]}
.
Well, I'm a little stumped, I gotta say. It was certainly fun refactoring the processor. I'm gonna sleep on this one and maybe I'll figure out how instaparse works.
Hi. The hiccup-tag-grammar is for parsing the keywords inside a hiccup structure. You probably don't need to touch it.
I see. So right now I'm trying to figure out where exactly the program takes in the strings. It seems like cljs.analyzer.api
is the library in gather-css-classes
that does the parsing. I found that it does something called passes
after taking in the whole file. So each of these passes
has some regex and destructuring for keywords and strings, it would seem that all I need to do is add some regex or something to take symbols in. That's where I'm stuck.
> Sorry, the analyzer is not so easy to use. Yes ..
I got it!!
Now I just gotta get the regex to work right.
What regex?
(def receive-hook-fn
{:keyword #(->> (name %)
(re-seq #"\.[^\.#]+")
(map (fn [s] (subs s 1))))
:string #(->> (str/split % #" ")
(remove str/blank?))
:symbol #(->> (name %)
(re-seq #"[\S]+"))})
I think this does it though, maybe there's a more elegant way to do that.
I may have time to take a look tonight.
Merged. Thank you !
Excellent. I'll be working on some documentation.
I just realized that this processor will take in strings, keywords, and symbols, however it does so indiscriminately. I guess that's why there was so much red text after the processor did its thing. How did you test the analyzer so you could see the AST of whatever file was put in?
Nevermind, I got the hang of it.
You were certainly right that it's difficult, but it's better than trying to use bean
on Java classes and methods.
There are plans to rewrite the processor at some point, using rewrite-clj, so no need to spend too much time on it.
The whole reason I'm working on this is because I want to use it on my website. I really want to get this working properly.
The "false positives" you are getting when gathering the symbols should not stop you in your process. I wouldn't worry about it if I was you. In the worse case, some of the symbols will match the grammar used by Girouette and your CSS file will be slighly bigger .. you might not even feel it.
Awww damn, I think I introduced a bunch of bugs into the program with this change. Not only is it detecting false positives, but it's also detecting false negatives.
I think I'll just have to convert all my classes to strings after all.
Should I revert the commit?
Yeah, it's probably for the best. Sorry I didn't test more.
I think it is already the case, except that it currently takes strings and not symbols.
hmmmm, let me test
Take a look at the example project in the repository.
Alright, following the above example, it looks like I can do {class '["inline-block" "underline"]}
.
So what's the most difficult part about making the tool consume symbols?
I'm looking through the codebase to find out what step the conversion happens.
It's not difficult to change. It's probably in the preprocessor project.
I found it, working on implementing it.
Perhaps you can point me in the right direction. I'm trying to get symbols to work, but I don't know what other steps in the chain I should look at. This is my progress so far. I also did a bit of refactoring as I saw fit, but feel free to ignore those changes if you think your way was more readable. https://github.com/wildwestrom/girouette/blob/develop/lib/processor/src/girouette/processor.clj
Sorry, the analyzer is not so easy to use.
I cannot look at it at the moment because I am still working.
I noticed that keywords are supported. Would that work for you?
They do work, and under certain circumstances I'll use them, but I still want to make this work. I'll keep at it.
I think that I did not support symbols by design, thinking that string and keywords would be good enough.
+1 for symbols. it's a small thing, but imo it adds up
Maybe I have to edit this function?
(def hiccup-tag-grammar "
hiccup-tag = html-tag (<'#'> id | (<'.'> class-name))*
html-tag = segment
id = segment
class-name = segment
<segment> = #'[^\\.#]+'
")