diff --git a/lib/svggvs/context.rb b/lib/svggvs/context.rb
index 55ab2ef..f9c5a02 100644
--- a/lib/svggvs/context.rb
+++ b/lib/svggvs/context.rb
@@ -53,6 +53,8 @@ module SVGGVS
session.file.dup_with_only_last_target.save target.to_s
+ session.file.clear_targets!
+
@individual_files << target
end
diff --git a/lib/svggvs/target.rb b/lib/svggvs/target.rb
index 90d69bc..a2dd53b 100644
--- a/lib/svggvs/target.rb
+++ b/lib/svggvs/target.rb
@@ -16,6 +16,14 @@ module SVGGVS
css("g[inkscape|groupmode='layer']").each do |layer|
if layers.include?(layer['inkscape:label'])
layer['style'] = ''
+
+ current_parent = layer.parent
+
+ while current_parent && current_parent.name == "g"
+ current_parent['style'] = ''
+
+ current_parent = current_parent.parent
+ end
else
layer['style'] = 'display:none'
end
@@ -44,7 +52,7 @@ module SVGGVS
end
if child.name == "image" && !!@replacements[label]
- child['xlink:href'] = @replacements[label]
+ child['xlink:href'] = ::File.expand_path(@replacements[label])
end
end
@@ -54,16 +62,19 @@ module SVGGVS
end
end
+ # only uncloning text
def unclone
css('svg|use').each do |clone|
if source = css(clone['xlink:href']).first
- new_group = clone.add_next_sibling("").first
+ if source.name == 'flowRoot' || source.name == 'text'
+ new_group = clone.add_next_sibling("").first
- clone.attributes.each do |key, attribute|
- new_group[attribute.name] = attribute.value
+ clone.attributes.each do |key, attribute|
+ new_group[attribute.name] = attribute.value
+ end
+
+ new_group << source.dup
end
-
- new_group << source.dup
end
clone.remove