Remove only auto generated id's

Bug #492277 reported by Porfirio
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Wishlist
Unassigned
Scour
Fix Released
Medium
Unassigned
scour (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

I use scour to clean svg files generated with inkscape.

In Inkscape all tags have an autogenerated ID, when you want to clean-up the document, to make it read faster or for convert to other format using a tool, you might want to remove all the uneused generated id's.

The --enable-id-stripping option, will strip all uneused id's, but there should be an option to only remove autogenerated id's

<rect id="rect46454"> --should be removed
<rect id="backGround"> -should stay

Tags: patch

Related branches

codedread (codedread)
Changed in scour:
status: New → Confirmed
Revision history for this message
Louis Simard (louis-simard-deactivatedaccount) wrote :

This change would greatly help those files with user-defined ID names referenced in <style> tags, while still removing useless ID names.

Since Inkscape's auto-generated names have digits at the end, user-defined names must have none. What do other vector editors' auto-generated names look like? (Adobe Illustrator, Sodipodi, etc.)

Changed in scour:
importance: Undecided → Medium
jazzynico (jazzynico)
Changed in inkscape:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Jan Thor (jan-janthor) wrote :

Unfortunately, no users of Adobe or Corel etc. came forward, but I think this would be tremendously helpful for Inkscape users. On the other hand, I think there are other use cases where one would assign prefixes to the id's of those elements with special meaning: for example, I could prefix the id's of those elements I want to use in scripts with 'jan:' or 'jan_', like, say, id="jan:page01", id="jan:page02" and so on.

Or perhaps I use the auto-generated id's Inkscape provides, write a script, and now I have a list of id's I use within my script and want to have protected. Therefore, I would propose we make several different mechanisms available, like this:

"""
--protect-ids-noninkscape
Don't remove id's which don't end with a digit (Inkscape auto-generated stock id's always end with digits, so only such id's get removed).

--protect-ids-list=comma_separated_list
Don't remove id's from this comma-separated list of protected id's.

--protect-ids-prefix=prefix
Don't remove id's which start with the given prefix. It is possible to provide more than one protective prefix by separating them with commas.

It is possible to combine these protections.
"""

Using these new options only makes sense if --enable-id-stripping has been set. I'm unsure which one is the least confusing addendum:

"""
Setting at least one of these three protection options automatically enables id stripping (as if --enable-id-stripping had been set).
"""

Or, instead, simply:

"""
Setting any of these three options only has an effect if --enable-id-stripping has been set.
"""

If there is interest, I'm willing to write a patch.

(We could also allow the users to provide a regular expression against which id's are matched, which would be a far more flexible approach, but I'm not sure that that would be the most helpful one.)

Revision history for this message
Jan Thor (jan-janthor) wrote :

I went ahead and wrote the patch.

Since in my implementation the protection of IDs not only prevents IDs from being stripped, but also from being shortened (if you want to keep IDs, presumably for scripting, I assume you'll want to keep them unabridged), I decided that it would be less confusing if providing a protective option doesn't automatically switch on the enable-id-stripping-option.

I also added the three new options to the Inkscape export code, but I left the server-side code untouched.

Revision history for this message
Louis Simard (louis-simard-deactivatedaccount) wrote :

Thanks for this patch (and all the others, again :). Your unit tests are sound, they pass, and the code works.

After a few patches went in, I'm going to retest with fulltests/* and some files from Ubuntu.

By server-side code, you mean webscour.py?

Changed in scour:
assignee: nobody → Louis Simard (louis-simard)
status: Confirmed → In Progress
Revision history for this message
Louis Simard (louis-simard-deactivatedaccount) wrote :

Everything checks out. I also could optimise the card game file from Ubuntu, with --protect-ids-noninkscape, without breaking AisleRiot Solitaire as it does if its card IDs (red_joker, 9_spades, etc.) are missing or shortened.

Your patch is in the trunk as revision 205.

Changed in scour:
status: In Progress → Fix Committed
Revision history for this message
Jan Thor (jan-janthor) wrote :

"By server-side code, you mean webscour.py?"

Indeed.

Martin Pitt (pitti)
Changed in scour (Ubuntu):
status: New → In Progress
tags: added: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package scour - 0.25+bzr207-1

---------------
scour (0.25+bzr207-1) unstable; urgency=low

  * New upstream bzr snapshot:
    - Add the option --no-renderer-workaround.
    - Fix gradient corruption. (LP: #702423)
    - Add option to only remove autogenerated id's. (LP: #492277)
    - Fix Windows line ending handling. (LP: #717826)
    - Fix occasional production of empty defs. (LP: #717254)
    - Remove more attributes with default values. (LP: #714731)
    - Fix wrong handling of file:// references. (LP: #708515)
    - Delete text attributes from groups with only non-text elements.
      (LP: #714727)
    - Remove unnecessary text-align properties from non-text elements.
      (LP: #714720)
    - Fix wrong optimization of 0-length Bézier curves. (LP: #714717)
    - Fix decimal number processing in rule_elliptical_arc(). (LP: #638764)
    - Fix transform matrix order. (LP: #722544)
  * Drop 01-bzr195.patch, upstream now.
  * debian/cmpsvg: Fix computation of difference to add up the absolute
    difference of each pixel.
  * debian/cmpsvg: Show percentages with three digits after comma.
  * debian/cmpsvg: Lower default treshold to 0.05%.
 -- Martin Pitt <email address hidden> Tue, 15 Mar 2011 09:28:45 +0100

Changed in scour (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Louis Simard (louis-simard-deactivatedaccount) wrote :

This bug is fixed in release 0.26 of Scour.

Changed in scour:
status: Fix Committed → Fix Released
Patrick Storz (ede123)
Changed in inkscape:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.