Improve whitespace normalization to support paragraphs.

Review Request #11025 — Created May 16, 2020 and submitted

Information

babel-plugin-django-gettext
master

Reviewers

The default whitespace normalization, used for non-raw versions of the
gettext functions, was pretty basic. It just collapsed down all
whitespace and trimmed the resulting string.

This works great for simple strings, but we've run into cases where we
have paragraphs of content we want to work with, and that wasn't at all
clean. The new support for plugins like dedent helps, but preserves
newlines, and that's exactly what we're trying to avoid.

This change improves the whitespace normalization to preserve
paragraphs. Any two paragraphs must be separated by one or more blank
lines. The whitespace normalization will be performed within each
paragraph. The final resulting string will normalize the blank lines
between each paragraph and trim the results.

Unit tests passed.

Manually tested with some code in Review Board.

Verified the rendered information in the README.

Summary ID
Improve whitespace normalization to support paragraphs.
The default whitespace normalization, used for non-raw versions of the gettext functions, was pretty basic. It just collapsed down all whitespace and trimmed the resulting string. This works great for simple strings, but we've run into cases where we have paragraphs of content we want to work with, and that wasn't at all clean. The new support for plugins like `dedent` helps, but preserves newlines, and that's exactly what we're trying to avoid. This change improves the whitespace normalization to preserve paragraphs. Any two paragraphs must be separated by one or more blank lines. The whitespace normalization will be performed within each paragraph. The final resulting string will normalize the blank lines between each paragraph and trim the results.
7e6257b0cafe027a8e84f5d042f0ca05d17ee576
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Loading...