Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format html tagged template text #9

Open
dsherret opened this issue Apr 4, 2020 · 1 comment
Open

Format html tagged template text #9

dsherret opened this issue Apr 4, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@dsherret
Copy link
Member

dsherret commented Apr 4, 2020

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...

@zandaqo
Copy link

zandaqo commented Jul 5, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants