From 7027c604de9b9981b2da7d51c7af73e382f9e9a2 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Sat, 23 Feb 2013 20:04:57 +0100 Subject: [PATCH] Tweak SVG parser id handling of text elements --- Nasal/canvas/svg.nas | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Nasal/canvas/svg.nas b/Nasal/canvas/svg.nas index 1de33a7ac..de180718b 100644 --- a/Nasal/canvas/svg.nas +++ b/Nasal/canvas/svg.nas @@ -510,7 +510,13 @@ var parsesvg = func(group, path, options = nil) * 1.25 # TODO read correct line spacing * stack[-1].get("character-size", character_size); - pushElement('text', tspan.attr['id']); + # Use id of text element with single tspan child, fall back to id of + # tspan if text has no id. + var id = text.attr['id']; + if( id == nil or size(tspans) > 1 ) + id = tspan.attr['id']; + + pushElement('text', id); stack[-1].set("text", tspan.text); if( x != 0 or y != 0 )