YAML callback: do not remove non-ASCII Unicode from multi-line string output (#1522) (#1529)

* Do not remove non-ASCII Unicode from multi-line string output.

* Added basic tests.

* Add Unicode test.

* Simplify tests, avoid later Jinja features.

* Refactor.

* Make use diy tests use callback test framework as well.

* Remove color codes.

* Work around stable-2.9 bug.

* Simplify again.

(cherry picked from commit 0a7ed3b019)

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot]
2020-12-22 09:59:57 +00:00
committed by GitHub
parent c0bb56c454
commit 5fa1fc65ca
9 changed files with 322 additions and 255 deletions

View File

@@ -50,7 +50,7 @@ def my_represent_scalar(self, tag, value, style=None):
# ...no trailing space
value = value.rstrip()
# ...and non-printable characters
value = ''.join(x for x in value if x in string.printable)
value = ''.join(x for x in value if x in string.printable or ord(x) >= 0xA0)
# ...tabs prevent blocks from expanding
value = value.expandtabs()
# ...and odd bits of whitespace