Skip to content

White-space only text nodes. #352

@Tavmjong

Description

@Tavmjong

Relevant links:
https://www.w3.org/TR/SVG2/struct.html#XMLSpaceAttribute
https://www.w3.org/TR/SVG2/text.html#WhiteSpaceProperty

The attribute xml:space is used to control white space in SVG 1.1 inside elements. As this is an XML attribute, it presumably must also follow XML rules for handling white-space only text nodes (different from text elements) which dictate that a value of "default" results in the removal of text nodes that only contain white space:

<text><tspan>A</tspan> <tspan>B</tspan></text> => AB

<text><tspan>A</tspan> B <tspan>C</tspan></text> => A B C

This behavior is not clearly defined in either the SVG 1.1 or SVG 2 specs and neither Firefox nor Chrome seem to follow this. Inkscape has followed this behavior (except due to a bug, now fixed, introduced by a change in the libxml2 library).

If this interpretation is wrong, then text should be added to the spec to make it clearer.

Note XHTML2 sets xml:space to preserve for all elements.

PS. It's a real pain that we can't attach SVG files!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions