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

Pretty Printer revamp #2286

Open
jhy opened this issue Mar 12, 2025 · 0 comments
Open

Pretty Printer revamp #2286

jhy opened this issue Mar 12, 2025 · 0 comments
Labels
improvement An improvement / new feature idea planned Things to get to in the near term

Comments

@jhy
Copy link
Owner

jhy commented Mar 12, 2025

I plan to revamp the HTML Pretty Printer. The current implementation is spread out through all the Node hierarchy, and is very brittle. Each different node type needs to understand the rules of the other types so they can print appropriately, and this has lead to some grotesque code.

To revamp I would centralize it into a specific consolidated function, that will take the node and a context. The context object can track stack related properties (as in, are we descended from a white-space sensitive element; is there any meaningful content already emitted at this level, etc).

This can also integrate with the changes in #2285 Custom Tags, so folks can specify their own properties.

We can also add some more configuration on the overall print (e.g. a tag list of "don't indent") so that body and head and their direct children don't need to be indented.

I also plan on simplifying the rules such that by default, a block tag only ever indents its children if one of those is also a block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement An improvement / new feature idea planned Things to get to in the near term
Projects
None yet
Development

No branches or pull requests

1 participant