From 703122369ed0c6a4e4217e7a77a8bf47d2ec3671 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 2 Jul 2018 22:14:14 +0200 Subject: [PATCH] Strip newlines from text nodes and be done with it Follow the spec "blindly" as it turns out covering all the border and getting reasonably styled output is just to cumbersome. This way at least scour output is consistent and it also saves us some bytes (a lot in some cases as we do not indent s etc. anymore) --- scour/scour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scour/scour.py b/scour/scour.py index 000142d..a46af61 100644 --- a/scour/scour.py +++ b/scour/scour.py @@ -3356,8 +3356,8 @@ def serializeXML(element, options, indent_depth=0, preserveWhitespace=False): if not preserveWhitespace: # strip / consolidate whitespace according to spec, see # https://www.w3.org/TR/SVG/text.html#WhiteSpace - # As a workaround for inconsistent handling of renderers keep newlines if they were in the original if element.nodeName in ['text', 'tspan', 'tref', 'textPath', 'altGlyph']: + text_content = text_content.replace('\n', '') text_content = text_content.replace('\t', ' ') if child == element.firstChild: text_content = text_content.lstrip()