Allow (partially) whitespace: pre
Right now, the only way to achieve whitespace presevation is by using xml:space. According to mdn this is outdated.
Nowadays there is the whitespace css properly.
So whitespace: pre should show all whitespaces (including newlines).
This is supported by Firefox. Chrome only supports multiple whitespaces and no newlines.
I vote for implementing chromes behavior because its trivial to implement. Just add an extra condition to this line:
https://github.com/yWorks/svg2pdf.js/blob/de6f4722b45eda4b2f9359059fd23cd9e09f0f34/src/nodes/text.ts#L53
If it is possible we should look into rendering newlines as well but that would probably take a bit more effort
Thank you for opening this feature request. I agree that we should implement it like Chrome does and don't support newlines for now. If Chrome does not support newlines it's unlikely that many SVGs will use this feature.
Could you prepare a PR? Here are some steps you could follow:
- add a
whiteSpaceproperty to the AttributeState, handle it like the other properties - adjust the usages of the
xmlSpaceproperty to also check for thewhiteSpaceproperty - add test cases similar to the "xml-space" tests
Please also see our contribution guidelines.
pr in https://github.com/yWorks/svg2pdf.js/pull/333
Partial support was implemented in #333. Newlines are still not supported.