-
Notifications
You must be signed in to change notification settings - Fork 96
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
Children print rework #160
Conversation
Goals: - switch logic around: prepare nodes before printing docs, try to avoid modifying printed result - respect user's wish to have line breaks sveltejs#143 sveltejs#117 - generally try to be more in line with how prettier formats things TODO: - either get tag break logic on par with prettier (breaking > into new lines etc) or adjust tests - more readable tag breaking logic for multiple children tags - tidy up
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.
This looks great! It's nice to get rid of the weird keepIfLonely
and the manipulation of the tree. I haven't looked at the code in a while and I must admit I'm not always sure what's going on, but it is simpler than the previous code. I'd generally welcome a couple of more comments though.
Thanks for the early feedback! Yeah this is in a rough state right now, I'll certainly add more comments and/or split out things into separate functions for more readability. All these different cases you need to keep in mind certainly don't make this easier 😄 |
It's incredibly difficult to overview the different cases, but structuring them according to the three cases you identified certainly seems to make it easier. |
This is finished now I hope. I would make this part of a 2.0 release along with some other breaking changes (default order change) just because so many things have changed and the way things break has slightly changed in some situations. |
|
||
const unsupportedLanguages = ['coffee', 'coffeescript', 'pug', 'styl', 'stylus', 'sass']; | ||
|
||
export function isInlineElement(node: Node) { | ||
return node.type === 'Element' && inlineElements.includes(node.name as TagName); | ||
} | ||
|
||
export function isBlockElement(path: FastPath, node: Node): node is ElementNode { | ||
// TODO switch to a list of tags instead |
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.
The idea is to switch to a defined list of block elements instead of a defined set of inline elements. That will deal with #159
fix break of block element followed by inline element
Goals: