Files
test-repo/changelog_unreleased/html/pr-8137.md
T
fisker Cheung f83eb9d5ef Preserve non-ASCII whitespace characters in HTML (#8137)
* Add html whitespace tests

* `U+0005` -> `U+2005`

* Update tests

* Fix whitespace

* Add changelog

* Another space

* Restore `non-breaking` check

* Add space between tests

* Extract all space related codes to utils

* Fix indent detect

* Update changelog

* Another space

* Rename

* Rename

* Rename

* Use `htmlTrimFirstLine` and `htmlTrimEnd`

* Assert with output

* `htmlTrimPreserveIndentation`

* Update changelog

* Fix another space
2020-04-25 16:56:28 +03:00

663 B

Preserve non-ASCII whitespace characters in HTML (#8137 by @fisker)

Non-ASCII whitespace characters like U+00A0 U+2005 etc. are not considered whitespace in html, they should not be removed.

// Prettier stable
[...require("prettier").format("<i> \u2005 </i>", { parser: "html" })]
  .slice(3, -5)
  .map((c) => c.charCodeAt(0).toString(16));

// -> [ '20' ]
// `U+2005` is removed

// Prettier master
[...require("prettier").format("<i> \u2005 </i>", { parser: "html" })]
  .slice(3, -5)
  .map((c) => c.charCodeAt(0).toString(16));

// -> [ '20', '2005', '20' ]