Open Tavmjong opened 7 years ago
Can you point to said XML rule (about white-space only text nodes)?
I know that we've willfully violated the white-space collapsing rules (using CSS rules like [1] essentially) since they are not very author friendly (as I believe would be obvious if applying said rules to your second example.)
[1] https://drafts.csswg.org/css-text-3/#white-space-processing
Firefox basically flattens the text and applies the rules on the post processed text i.e. A B or A B C. That way adding tspan elements doesn't in itself change the layout. That's also compatible with html text processing.
Not blocking updated 2.0 CR publication - assigning 2.1 WD milestone
Here the example in CodePen https://codepen.io/krit/pen/MZWeJd
It seems like all browsers render the text snippet the same and do not ignore the white space. @Tavmjong so you think xml:space
is not compatible to the white-space
property? If so, would we need to define the behavior of xml:space
to follow the behavior of white-space
in stead?
That's how Firefox works right now. I.e it maps xml:space to CSS white-space
The SVG Working Group just discussed White-space only text nodes.
, and agreed to the following:
RESOLUTION: `xml-space` attribute does not affect parsing of whitespace nodes.
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!