dprint-plugin-typescript
dprint-plugin-typescript copied to clipboard
Format html tagged template text
It would be nice to format html in tagged templates as Prettier does.
For example:
const t = html `
<tr>
<td class="mode">
${entry.mode}
</td>
<td>
${entry.size}
</td>
<td>
<a href="${entry.url}">${entry.name}</a>
</td>
</tr>
`;
Should format as:
const t = html`
<tr>
<td class="mode">
${entry.mode}
</td>
<td>
${entry.size}
</td>
<td>
<a href="${entry.url}">${entry.name}</a>
</td>
</tr>
`;
This will probably be a bit of work though...
From HN:
It's definitely something I would like to implement. I haven't found a parser that would be good for formatting yet so maybe I will have to write my own :/
Could sax-wasm be a good fit here? It's an HTML parser written in Rust, and I believe I've seen a few folks in Lit community using it with their tagged templates.