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

chore: strip out whitespace added by jinja blocks #14709

Merged
merged 2 commits into from
Oct 10, 2023

Conversation

miketheman
Copy link
Member

When looking at source of HTML, we emit whitespace around Jinja blocks.

While individual blocks can opt out of emitting this whitespace with - control characters (like robots.txt did), it is simpler to apply this as a global setting.

On pages like /help/, these settings remove some 500 lines of whitespace from the output.

Refs: https://jinja.palletsprojects.com/en/3.0.x/templates/#whitespace-control

When looking at source of HTML, we emit whitespace around Jinja blocks.

While individual blocks can opt out of emitting this whitespace with `-`
control characters (like `robots.txt` did), it is simpler to apply this
as a global setting.

On pages like `/help/`, these settings remove some 500 lines of
whitespace from the output.

Refs: https://jinja.palletsprojects.com/en/3.0.x/templates/#whitespace-control

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
@miketheman miketheman added the HTML requires change to HTML files label Oct 6, 2023
@miketheman miketheman requested a review from a team as a code owner October 6, 2023 16:44
@miketheman miketheman merged commit 8949061 into pypi:main Oct 10, 2023
@miketheman miketheman deleted the miketheman/jinja-whitespace branch October 10, 2023 13:20
@di
Copy link
Member

di commented Oct 30, 2023

FYI, looks like this is causing some missing spaces in places where we previously expected newlines to get converted to whitespace:

image

This example is from https://github.com/pypi/warehouse/blob/b2a306fbc6e1087d484f422863b31d569cf09d8b/warehouse/templates/packaging/detail.html#L382C1-L383

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HTML requires change to HTML files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants