nebulab / erb-formatter

Format ERB files with speed and precision
MIT License
135 stars 22 forks source link

Use syntax-tree-erb #25

Open elia opened 1 year ago

elia commented 1 year ago

Consider joining forces with https://github.com/davidwessman/syntax_tree-erb as the project has done an awesome job already and with a few fixes we could get feature parity.

Currently trying to run it on existing fixtures has the following issues:

cc @davidwessman the pretty print based approach of SyntaxTree is far superior to the long formatting script in this project, I thought was good to let you know I'm considering switching to it entirely in case you're interested in helping out 🙌

davidwessman commented 1 year ago

Cool 😊 I am totally up for helping out, will check it out when I'm back at my computer.

davidwessman commented 1 year ago

I have been off for the summer, but I am now looking at how to handle whitespace differntly. Not satisfied with any solution yet :/

davidwessman commented 1 year ago

@elia Could you test out https://github.com/davidwessman/syntax_tree-erb/pull/51 and see if it makes sense to you?

This was my third take and the first time I managed to make all test pass. It feels like this will give more edge-cases, maybe I will have to reconsider it a few more times.

davidwessman commented 1 year ago

@elia Now I feel more pleased with the changes syntax_tree-erb does on your test cases. Please give v0.10.5 a try 🙂 I do not have any good idea for handling e.g. frontmatter yet.

elia commented 1 year ago

@davidwessman that's awesome! I just checked it out and it works perfectly 🙌 I think for now we can have a thin layer removing and re-adding the front matter whenever is detected like it's currently done in erb-formatter.

I'll give it a crack and send a PR if I get somewhere 👍

davidwessman commented 1 year ago

Nice 😊

I am thinking about how to handle style and javascript-blocks, so I might be able to solve frontmatter as well.

Is ERB allowed inside the frontmatter?