zackad / prettier-plugin-twig

Code formatting plugin for Prettier to handle Twig templates
Apache License 2.0
55 stars 6 forks source link

support attribute names according to html5 specs #38

Closed hanoii closed 3 months ago

hanoii commented 4 months ago

Fixes #37

hanoii commented 4 months ago

I added some tests and fixes another issue I found with attribute values.

Just as a comment and not sure if you can share your own insight as I attacked this issue from the end rather than from the start, I do wonder why a melody parser is needed and not maybe based it on top of the html one. I also wonder why prettier-plugin-tailwindcss (which I am most interested in using) need to know about the different parsers out there. I guess this is a current limitation of a prettier plugin development, but as I haven't started from there I am unaware.

I did submit https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/307 but then I realize what you were doing with the rename, that will be necessary though. I have a better understanding now of the melody parser, but still a bit in the dark of the whole picture.

zackad commented 3 months ago

Hi @hanoii, thanks for your pull request. Glad to see that people takes interest in this project.

I don't know why this project use custom parser to handle twig template. It just the way this project is when I start forking it. My gut feeling tell me that html parser might not be able to recognize twig syntax. The original project doesn't receive update since 2020. Lots of things might have changed. But I don't really following prettier project.

As for why prettier-plugin-tailwindcss need to know about other plugin, they provide some workaround for compatibility0 with with other prettier plugin. As you can see from their docs1, tailwindcss plugin need to be loaded last.

Other than formatting error, your PR looks good to me.

Notes: Don't use npm script to run prettier. It has incorrect option that will mess up your code. It might be removed in the future.

Ref: