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

Transformer: Trim whitespace in body text nodes #12

Closed
schlessera opened this issue Mar 27, 2020 · 5 comments
Closed

Transformer: Trim whitespace in body text nodes #12

schlessera opened this issue Mar 27, 2020 · 5 comments
Assignees
Milestone

Comments

@schlessera
Copy link
Collaborator

Feature description

Add logic to the existing Minify transformer so that it collapses and trims whitespace in body text nodes

Related ampproject/amp-wp#4213


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • Generated HTML output from the Optimizer is minified
  • The text nodes within <body> only contain the essential whitespace to maintain their displayed result

Implementation brief

QA testing instructions

Demo

Changelog entry

@westonruter
Copy link
Member

Is this not a duplicate of ampproject/amp-wp#4454?

@schlessera
Copy link
Collaborator Author

Is this not a duplicate of ampproject/amp-wp#4454?

No, this is about trimming whitespace within the ->textContent of a node.

@westonruter
Copy link
Member

How is that not the same as:

collapse whitespace (except in <pre>, <textarea>, <script>)

@schlessera
Copy link
Collaborator Author

ampproject/amp-wp#4454:

<div>
   <ul>
      <li>something</li>
   </ul>
</div>

=>

<div><ul><li>something</li></ul></div>

ampproject/amp-wp#4456:

<p>      Some
      text that is wrapped
    across multiple
      lines      </p>

=>

<p> Some text that is wrapped across multiple lines </p>

Note that the complexity is a different one for text nodes, as some whitespace can be removed while similar whitespace in a different position might have an impact on rendering.

@schlessera schlessera transferred this issue from ampproject/amp-wp Nov 6, 2020
@schlessera
Copy link
Collaborator Author

Fixed via #251

@schlessera schlessera added this to the 0.8.0 milestone Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants