Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
HTML: Add parse5/htmlparser2 printer #2083
Parse5 was chosen due to compliance, and the ability to switch between different AST representations.
The htmlparser2 AST was chosen since it is simpler to work with in prettier. parse5's default AST doesn't track
Similar to the method used to implement CSS template string formatting (#1948), the idea is to first introduce a fully compliant HTML5 printer, then use heuristics to switch to:
This is very exciting!
Off the top of my head I'm not sure of the best way to share the formatting logic with JSX, but I'm hopefully we can share some logic.
The JSX formatting is about to get an overhaul in #1831.
We should probably base the HTML formatting on the logic in that PR. It may make sense for HTML formatting to initially take a copy of the JSX logic and modify it as needed, as HTML has a lot fewer edge cases (no JSX whitespace or Facebook translation pipeline support).
Once we have HTML formatting sorted we could then start looking at how it and JSX formatting can share code.