You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inkscape 1.0 has different element and attribute order when exporting.
When I export this file in Inkscape 1.0 (compared to the existing Inkscape 0.92 file), almost all of it will have been touched, leading to unreadable git diff.
I wrote a small (and ugly) script to deal with this:
#!/usr/bin/python3importsysfromxml.domimportminidomold_svg=minidom.parse(sys.argv[1])
new_svg=minidom.parse(sys.argv[2])
old_paths= [path.getAttribute('id') forpathinold_svg.getElementsByTagName('path')]
new_paths= [path.getAttribute('id') forpathinnew_svg.getElementsByTagName('path')]
removed= []
forold_pathinold_paths:
ifnotold_pathinnew_paths:
removed+= [old_path]
added= []
fornew_pathinnew_paths:
ifnotnew_pathinold_paths:
added+= [new_path]
#print(removed)#FIXME: Check modified#print(added)clean_xml=minidom.Document()
clean_svg=clean_xml.createElement("svg")
foradded_idinadded:
#FIXME: Instead, save the full element path so we also know which layer it came fromforpathinnew_svg.getElementsByTagName('path'):
ifpath.getAttribute('id') ==added_id:
path_id=path.getAttribute('id')
path_d=path.getAttribute('d')
path_style=path.getAttribute('style') #FIXME: Remove most of this#FIXME: Warn about any other attribute clean_path=clean_xml.createElement("path")
clean_path.setAttribute('id', path_id)
clean_path.setAttribute('d', path_d)
clean_path.setAttribute('style', "fill:none;stroke:#ff0000;stroke-width:1.25;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1")
clean_svg.appendChild(clean_path)
print(clean_path.toxml())
open("clean.svg", "w").write(clean_svg.toxml())
old_svg.unlink()
new_svg.unlink()
So this lists the changes and allows me to create a more standardized file format.
The script above was a crude prototype.
We probably want a pair of scripts to resolve this:
A script to reduce the number of SVG features, so that the file in the repository is always dumbed down.
A script to generate a diff from 2 SVGs, so we can highlight changes done between 2 revisions (to ease review).
Feature wise, our "dumb SVG" will only have to support:
Paths (for traces): either stroked OR filled (so the "style" is one of these two), stroke width (maybe just a fixed number of allowed ones?), the path ID and geometry; the rest of the features (including various attributes) can be dropped or added on demand.
Rectangles / Circles (for vias and pads): features to be determined.
Groups / Layers (for organizing the file): features to be determined.
Images (for the background, so this can be very simple): features to be determined.
The elements would have to be sorted by their ID, so that re-arranging anything wouldn't lead to trouble.
This would help with creating consistency and allow other tools to be used.
The text was updated successfully, but these errors were encountered:
Inkscape 1.0 has different element and attribute order when exporting.
When I export this file in Inkscape 1.0 (compared to the existing Inkscape 0.92 file), almost all of it will have been touched, leading to unreadable
git diff
.I wrote a small (and ugly) script to deal with this:
So this lists the changes and allows me to create a more standardized file format.
The script above was a crude prototype.
We probably want a pair of scripts to resolve this:
Feature wise, our "dumb SVG" will only have to support:
The elements would have to be sorted by their ID, so that re-arranging anything wouldn't lead to trouble.
This would help with creating consistency and allow other tools to be used.
The text was updated successfully, but these errors were encountered: