Pug pretty compilation and inline element whitespace
0 reputation · 08 May 2022, 11:39 UTC
Pretty Printing Configuration
The pretty compilation option in Pug (v3.x) is designed to insert newlines and indentation into the generated HTML to improve the readability of the output markup. While this is effective for block-level elements, the compiler utilizes a hard-coded internal list to distinguish between block and inline tags when determining where to insert whitespace.
Whitespace Consistency Constraints
Because the classification of inline elements is static and not exposed via the public API, certain HTML5 elements may be treated inconsistently. This can result in the insertion of unintended whitespace between inline siblings, which browsers may render as visible gaps, or the omission of necessary spacing, causing text to run together.
There is currently no configuration property to extend the internal list of inline tags or to override the whitespace heuristic for specific elements without modifying the compiler source.
- Does Pug provide a mechanism to customize the internal tag classification used by the pretty printer?
- Is there a documented way to prevent the
prettyoption from adding whitespace specifically to inline siblings while maintaining indentation for block elements?