Repository: meerk40t/svgelements

Issue:
Parsing Inkscape text elements results in missing element IDs
When trying to access text elements created in Inkscape, the parser does not get the element ids correctly. This might be due to ` id="text3785"><tspan` and a simple regular expression could solve the issue.

```py
import svgelements

# svgFileName = "path/to/svg"

layout = svgelements.SVG.parse(
    source = svgFileName, 
    reify = True,
    ppi = svgelements.svgelements.DEFAULT_PPI,
    width = 1,
    height = 1,
    color = "black",
    transform = None,
    context = None
)

[element.id for element in layout.elements()]
# ['svg3040', 'namedview3042', 'layer1', None, None, None, None, None, None]
```

```xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   width="210mm"
   height="297mm"
   viewBox="0 0 210 297"
   version="1.1"
   id="svg3040"
   inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
   sodipodi:docname="test12.svg"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <sodipodi:namedview
     id="namedview3042"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageshadow="2"
     inkscape:pageopacity="0.0"
     inkscape:pagecheckerboard="0"
     inkscape:document-units="mm"
     showgrid="false"
     inkscape:zoom="0.72337262"
     inkscape:cx="396.75265"
     inkscape:cy="561.95105"
     inkscape:window-width="1920"
     inkscape:window-height="1001"
     inkscape:window-x="-9"
     inkscape:window-y="-9"
     inkscape:window-maximized="1"
     inkscape:current-layer="layer1" />
  <defs
     id="defs3037" />
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1">
    <text
       xml:space="preserve"
       style="font-size:18px;line-height:1.25;font-family:sans-serif;stroke-width:0.264583"
       x="30.724138"
       y="44.988914"
       id="text3785"><tspan
         sodipodi:role="line"
         id="tspan3783"
         style="stroke-width:0.264583"
         x="30.724138"
         y="44.988914">Test</tspan></text>
    <text
       xml:space="preserve"
       style="font-size:18px;line-height:1.25;font-family:sans-serif;stroke-width:0.264583"
       x="67.300491"
       y="110.46059"
       id="text4119"><tspan
         sodipodi:role="line"
         id="tspan4117"
         style="stroke-width:0.264583"
         x="67.300491"
         y="110.46059">TestTest</tspan></text>
    <text
       xml:space="preserve"
       style="font-size:18px;line-height:1.25;font-family:sans-serif;stroke-width:0.264583"
       x="67.300491"
       y="172.6404"
       id="text4519"><tspan
         sodipodi:role="line"
         id="tspan4517"
         style="stroke-width:0.264583"
         x="67.300491"
         y="172.6404">123</tspan></text>
  </g>
</svg>
```

Comments:

Patch:
diff --git a/setup.cfg b/setup.cfg
index 060baf4..ad41d40 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = svgelements
-version = 1.6.5
+version = 1.6.6
 description = Svg Elements Parsing
 long_description_content_type=text/markdown
 long_description = file: README.md
diff --git a/svgelements/svgelements.py b/svgelements/svgelements.py
index 433aedb..8c83c91 100644
--- a/svgelements/svgelements.py
+++ b/svgelements/svgelements.py
@@ -43,7 +43,7 @@ Though not required the Image class acquires new functionality if provided with
 and the Arc can do exact arc calculations if scipy is installed.
 """
 
-SVGELEMENTS_VERSION = "1.6.5"
+SVGELEMENTS_VERSION = "1.6.6"
 
 MIN_DEPTH = 5
 ERROR = 1e-12
@@ -7834,6 +7834,7 @@ class Text(SVGElement, GraphicObject, Transformable):
     def property_by_values(self, values):
         Transformable.property_by_values(self, values)
         GraphicObject.property_by_values(self, values)
+        SVGElement.property_by_values(self, values)
         self.anchor = values.get(SVG_ATTR_TEXT_ANCHOR, self.anchor)
         self.font_face = values.get("font_face")
         self.font_face = values.get(SVG_ATTR_FONT_FACE, self.font_face)
@@ -8080,6 +8081,7 @@ class Image(SVGElement, GraphicObject, Transformable):
     def render(self, **kwargs):
         GraphicObject.render(self, **kwargs)
         Transformable.render(self, **kwargs)
+        SVGElements.render(self, **kwargs)
         width = kwargs.get("width", kwargs.get("relative_length"))
         height = kwargs.get("height", kwargs.get("relative_length"))
         try:


Test patch:
diff --git a/test/test_text.py b/test/test_text.py
new file mode 100644
index 0000000..860a081
--- /dev/null
+++ b/test/test_text.py
@@ -0,0 +1,26 @@
+import io
+import unittest
+
+from svgelements import *
+
+
+class TestElementText(unittest.TestCase):
+
+    def test_issue_157(self):
+        q = io.StringIO(u'''<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg>
+  <g id="layer1">
+    <text
+       style="font-size:18px;line-height:1.25;font-family:sans-serif;stroke-width:0.264583"
+       id="textobject"><tspan
+         id="tspanobject"
+         x="0"
+         y="0">Test</tspan></text>
+  </g>
+</svg>
+        ''')
+        m = SVG.parse(q)
+        q = list(m.elements())
+        self.assertIsNotNone(q[1].id) # Group
+        self.assertIsNotNone(q[2].id) # Text
+        self.assertIsNotNone(q[3].id) # TSpan