Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

collapse_whitespace in <code> #1772

Closed
Dreamsorcerer opened this issue May 28, 2018 · 1 comment
Closed

collapse_whitespace in <code> #1772

Dreamsorcerer opened this issue May 28, 2018 · 1 comment

Comments

@Dreamsorcerer
Copy link
Contributor

The documentation says:

..is normally ignored by the browser outside of tags like <pre> and <textarea>, one can use CSS properties such as "white-space: pre" to make the browser preserve whitespace within a portion of the document..

It would be nice if collapse_whitespace would also ignore <code> tags, as these are quite a common case for "white-space: pre".

Additionally, MDN says:

The HTML <code> element displays its contents styled in a fashion intended to indicate that the text is a short fragment of computer code.

Based on that description, it's plausible that a browser may choose to pay attention to whitespace, where it normally wouldn't (given that, for example, Python code without the whitespace would be invalid code).

So, skipping <code> content would make this filter a fair bit safer to use.

@oschaaf
Copy link
Member

oschaaf commented May 28, 2018

Sounds reasonable to me, and looks like it's easy to accomplish. It looks like it is just a matter of adding <code> to kSensitiveTags here:

https://github.com/apache/incubator-pagespeed-mod/blob/master/pagespeed/kernel/html/collapse_whitespace_filter.cc#L39

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants