diff options
| author | Thomas Holder <thomas@thomas-holder.de> | 2019-10-16 12:36:34 +0000 |
|---|---|---|
| committer | Thomas Holder <thomas@thomas-holder.de> | 2019-10-16 17:56:41 +0000 |
| commit | 00875b3e762cabc9b293c0908d73f921cc991835 (patch) | |
| tree | 0b2ec6cba7b2d64c11c26cdf2c95450bca9bc828 /src/xml | |
| parent | Extensions: Disable effects that failed to load (diff) | |
| download | inkscape-00875b3e762cabc9b293c0908d73f921cc991835.tar.gz inkscape-00875b3e762cabc9b293c0908d73f921cc991835.zip | |
fix SVG writing with xml:space="preserve"
- xml:space check got lost in b0be54c825
- no unconditional newline after "svg:text"
- differentiate parent and child xml:space
Diffstat (limited to 'src/xml')
| -rw-r--r-- | src/xml/repr-io.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 7b76a3086..ac9794ecd 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -957,6 +957,7 @@ void sp_repr_write_stream_element( Node * repr, Writer & out, { Node *child = nullptr; bool loose = false; + bool const add_whitespace_parent = add_whitespace; g_return_if_fail (repr != nullptr); @@ -986,6 +987,14 @@ void sp_repr_write_stream_element( Node * repr, Writer & out, if (strcmp(repr->name(), "svg:text") == 0 || strcmp(repr->name(), "svg:flowRoot") == 0) { add_whitespace = false; + } else { + // Suppress formatting whitespace for xml:space="preserve" + gchar const *xml_space_attr = repr->attribute("xml:space"); + if (g_strcmp0(xml_space_attr, "preserve") == 0) { + add_whitespace = false; + } else if (g_strcmp0(xml_space_attr, "default") == 0) { + add_whitespace = true; + } } for ( List<AttributeRecord const> iter = rebase_href_attrs(old_href_base, new_href_base, @@ -1038,10 +1047,7 @@ void sp_repr_write_stream_element( Node * repr, Writer & out, out.writeString( " />" ); } - // text elements cannot nest, so we can output newline - // after closing text - - if (add_whitespace || !strcmp (repr->name(), "svg:text")) { + if (add_whitespace_parent) { out.writeChar('\n'); } } |
