Skip to content

Commit

Permalink
Construct ID URLs with get_id(as_url=2)
Browse files Browse the repository at this point in the history
inkex already provides this mechanism so it's cleaner to use it as is
rather than reimplement it.
  • Loading branch information
spakin committed Dec 19, 2023
1 parent 423f000 commit 28e9cce
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions simpinkscr/simple_inkscape_scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def __init__(self, obj, transform, conn_avoid, clip_path_obj, mask_obj,
else:
if not isinstance(clip_path_obj, SimpleClippingPath):
clip_path_obj = clip_path(clip_path_obj)
clip_str = 'url(#%s)' % clip_path_obj._inkscape_obj.get_id()
clip_str = clip_path_obj._inkscape_obj.get_id(as_url=2)
obj.set('clip-path', clip_str)

# Optionally employ a mask.
Expand All @@ -410,7 +410,7 @@ def __init__(self, obj, transform, conn_avoid, clip_path_obj, mask_obj,
else:
if not isinstance(mask_obj, SimpleMask):
mask_obj = mask(mask_obj)
mask_str = 'url(#%s)' % mask_obj._inkscape_obj.get_id()
mask_str = mask_obj._inkscape_obj.get_id(as_url=2)
obj.set('mask', mask_str)

# Combine the current and default styles.
Expand All @@ -432,7 +432,7 @@ def __str__(self):
'''Return the object as a string of the form "url(#id)". This
enables the object to be used as a value in style key=value
arguments such as shape_inside.'''
return 'url(#%s)' % self._inkscape_obj.get_id()
return self._inkscape_obj.get_id(as_url=2)

def __eq__(self, other):
'''Two SimpleObjects are equal if they encapsulate the same
Expand Down Expand Up @@ -1457,7 +1457,7 @@ def get_inkex_object(self):
return self.filt

def __str__(self):
return 'url(#%s)' % self.filt.get_id()
return self.filt.get_id(as_url=2)

class SimpleFilterPrimitive(SVGOutputMixin):
'Represent one component of an SVG filter effect.'
Expand Down Expand Up @@ -1553,7 +1553,7 @@ def _set_common(self, grad, repeat=None, gradient_units=None,
grad.set('inkscape:collect', 'always')

def __str__(self):
return 'url(#%s)' % self.grad.get_id()
return self.grad.get_id(as_url=2)

def add_stop(self, ofs, color, opacity=None, **style):
'Add a stop to a gradient.'
Expand Down

0 comments on commit 28e9cce

Please sign in to comment.