TextElement.get_text() is broken / misbehaving (again)
Summary:
TextElement.get_text() is broken again. It's both adding phantom whitespace and missing nested elements. It's breaking gcodetools. You can't see it on the official repo (since tests haven't run), but mine: https://gitlab.com/Egilsson/inkscape-extensions-gcodetools/-/jobs/6249946319
Warning! Tool has parameter that default tool has not ( 'name
': 'Default tool
' ).
Gcodetools uses get_text() to fetch values and get_text() is appending phantom whitespace. I know we could just add a strip() to the returned value, but there are other problems too. I also don't think any changes will be accepted into Gcodetools until it has proper test coverage (which is what I'm trying to work on!)
I wrote some thorough whitespace tests for get_text(): extensions!619 (closed)
I think this all started with this MR, when get_text() started to return None: extensions!584 (merged) Then this fix, but I don't think that's the culprit: extensions@24c81866
There is definitely a problem with this: https://gitlab.com/inkscape/extensions/-/blob/master/inkex/elements/_text.py?ref_type=heads#L167 node.tail often contains a newline when it shouldn't.
Probably something for the members of !584 (merged) to have a rethink.
The classic way to deal with excessive whitespace is to strip() it away. But the problem is that we don't know what the plugins are going to do with text from get_text(), so it doesn't seem right to mess with the text.
Steps to reproduce:
Checkout extensions!619 (closed) and have a go locally to get the tests to pass.
What happened?
get_text() got broken ...
What should have happened?
get_text shouldn't' have been broken :) ...
Sample attachments:
Version info
master/main of everything.