Support HTMLx
See original GitHub issue(I removed the issue boilerplate because it doesn’t seem to pertain to feature requests — hope that’s okay.)
@vjeux sent me here! On the Svelte project, we’re often asked if it it’s possible to use Prettier to format single-file components. At present the answer is ‘no, not reliably’, because we typically write those components in .html
files, and components are written in a superset of HTML called HTMLx.
Since Prettier supports Angular and Vue flavours of HTML already, I wondered what it would take to support HTMLx in addition? (We’re considering adopting and promoting an .htmlx
extension similar to .vue
, if that’s necessary.) We’d obviously be happy to do the work, I’m just raising this issue to see if a PR adding support would be likely to be accepted.
(Note that HTMLx will change slightly for Svelte 3, out soon.)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:12 (9 by maintainers)
Top GitHub Comments
I’ve made prettier-plugin-svelte. Is it preferred that things are built in to prettier, or provided as plugins? I don’t know how hard it would be to integrate what I’ve done into prettier but willing to give it a go if I find some time
Assuming our HTML/Vue/Angular parser can already parse everything you need, add an entry for htmlx here and then adjust the printing to support htmlx-specific semantics in this file. The way the printer works is it returns an intermediate representation of the text called a “document” that is comprised of various nodes which are informally documented here. The logic here where we handle vue’s
v-for
attribute may be a good place to start.