Skip to content

Support pretty-printing and whitespace management #54

@davepeck

Description

@davepeck

I need to think more carefully about whitespace handling.

You can’t just trim all the strings, since whitespace is (to a degree) significant in HTML.

At the same time, precise whitespace preservation from t-string literal to final output is clearly not a goal: some of the whitespace in the HTML we process will be incidental, as a side effect of code formatting in Python itself.

I propose adding a render() method to the Node hierarchy; str() will invoke it directly. We should support a “compact” (all whitespace removed except significant whitespace) and a “pretty” (multiline and indented, for debugging if for nothing else) output mode. Probably we need to support an "exact" mode as well, since <pre> tags, etc. should keep spacing unaltered.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions