-
Notifications
You must be signed in to change notification settings - Fork 97
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
[WIP] Fix handling of inline and preformatted tags #41
Conversation
@@ -0,0 +1,4 @@ | |||
<a> | |||
<MyIcon /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should we handle block elements inside inline elements? Should they wrap as normal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I think wrap as normal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, so it looks like Prettier handles this differently (with htmlWhitespaceSensitivity
set to strict
or css
): even with child block tags, it doesn't break immediately after the opening tag nor immediately before the closing tag.
Coincidentally, that behavior is the easiest way to implement the fixes for inline elements in this plugin. Here's the updated behavior
Looks good so far 👍 |
- Split various element tests into separate tests for inline and block tags - Add tests for various scenarios involving inline tags, including inside other tags and alongside text nodes - Add test for not reformatting text inside `<pre>` tags
Add definitions for all elements, preformatted elements, and inline elements (as specified by TypeScript and Mozilla Developer Network).
Add options for specifying what tags should be treated as inline and preformatted elements.
- Collect inline element tags (as defined by the `svelteInlineElements` option) into inline groups when printing children. - When printing children of inline elements, don't add surrounding lines around the child contents
Don't break immediately after the opening tag or immediately before the closing tag, even with block element children.
What do you think, will this PR also solve #58 or is that a different issue? |
This is a great PR. What else needs to be done? |
Hey sorry, it's been a while since I've looked at this. From my checklist, it seems I was stuck on making the configuration of inline/preformatted tags as flexible as possible since Prettier didn't have a proper Also, maybe more tests? 😬 |
@jarrodldavis can I help get this PR across the finish line? |
@awmottaz Feel free to fork/copy over my branch and make your own PR based on this one. I don't have the time right now to finish this, sorry. |
I'm opening this pull request early to get feedback on the tests I added before finishing the fixes I had in mind.
<pre>
<pre>
(fixes Configure whitespace-sensitive tags #28)The following seem like they will be hard to do until a
string
option type is provided by Prettier (see prettier/prettier#6151):