-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Verbose SVG for improved human readability #340
Comments
What if there are multiple identical children? Sounds like a nightmare for performance, all the parents would need to listen for child content changes. I think I'm going to decline to implement this or see it implemented natively in Firefox. You could always write some kind of XSLT transform that implements your syntax and converts it to SVG native. Good luck with that as I think it's the way forward for you here. |
This would be a bit like what content MathML is to presentation MathML? But I see even less for this here since e.g. the semantic aspect for screen readers isn't there. |
I'm not sure why you would want to do it this way.
|
My main issue is with the syntax within the File size is not an issue for this particular use case. I also doubt that the difference is huge after compression has been applied, especially when compared to non-minified hand-written code which includes optional but helpful commas and whitespace. I’m not strongly attached to the proposed If one of SVG’s strongest advantages wasn’t its readability by humans, it could have been a more efficient non-XML, binary format in the first place. The syntax extension I am proposing would be an optional superset that can be converted easily to the traditional style. It is just more verbose. @longsonr is right, I could preprocess a custom syntax into standard SVG, but that would benefit only myself, hence my suggestion to standardize it. My point is that parts of the current syntax are hostile to potential new authors. Path syntax also does not afford helpful GUI solutions. I don’t get the JavaScript argument. Yes, additional nodes make the tree more complex, but they also make working with them more straightforward. Imagine a graphical image editor: if you are dragging an anchor point, it makes more sense and feels much cleaner to alter a single child element than to update a random part of a textual attribute node. In other words, it is a more appropriate mapping of the mental and visitation models into code. This is also true in particular for the difference between absolute and relative coordinates that are currently realized by the case of single letters. |
Given that most people would edit or create SVGs in a program like Inkscape, Adobe Illustrator, CorelDraw etc, readability is a non-issue. If it is for you, I would suggest just writing a script to insert a new line after each segment of a path.
The current d attribute in path is logical. You can follow along each step of the way and know what it is doing, especially if everything is along relative paths. Mixing absolute points in requires more of an understanding about where the path is located overall, which can make things difficult. If you are struggling, why not throw in a quick h5h-10h5v5v-10v5 (adjust size to appropriate value), when you're editing, so you get a big + when displaying the SVG. As to the javascript, if it expects an SVG element with AttributeNS, but your non standard SVG is served, it would need to instead loop through child nodes looking for values. So existing code would break. |
Not blocking updated 2.0 CR publication - assigning 2.1 WD milestone |
I remembered this proposal today, because it would provide something for free that SVG does not have yet (as far as I know): named coordinates and reusable dimensions. <defs>
<p id="wxh" dx="123" dy="45"/>
<p id="xy1" x="67" y="89"><desc>upper left corner of rectangle</desc></p>
<p id="xy2" x="190" y="134"/>
</defs>
<rect><!-- 1 absolute and 1 relative point -->
<use xlink:href="#xy1"/>
<use xlink:href="#wxh"/>
</rect>
<rect><!-- 2 absolute points specify two corners -->
<use xlink:href="#xy1"/>
<use xlink:href="#xy2"/>
</rect> |
w3c/csswg-drafts#5674 reminded me of this issue today. Instead of a universal <defs>
<by id="wxh" x="123" y="45"/>
<to id="xy1" x="67" y="89"/>
<to id="xy2" x="190" y="134"/>
</defs> <defs>
<rel id="wxh" x="123" y="45"/>
<abs id="xy1" x="67" y="89"/>
<abs id="xy2" x="190" y="134"/>
</defs> |
You can achieve some of what you want with CSS variables on the elements that have their positioning as CSS properties i.e. circle, ellipse, rect |
Just for the record, Fitbit supports a proprietary
|
I wish there was a supplementary superset of SVG that made the
rect
,circle
/ellipse
,line
,polyline
andpolygon
optionally have a number ofp
children. The number of mandatory and optionalp
children varies by element type.The
p
element is a point or coordinate, specified either absolutely byx
andy
attributes or relatively bydx
anddy
attributes. They all default to0
initially, butx
andy
inherit the computed values of the previous sibling – or cousin inpath
– point. If both,x
anddx
ory
anddy
, are specified the relative values are added to the absolute ones to give the computed coordinate.I believe a superset syntax like this would make editing by hand, especially reading, easier. The transformations to the legacy syntax are straightforward, but for these elements the argument is probably not convincing enough. It gets handier with elements that support more, i.e. an arbitrary number of points:
The
path
element on the other hand would have an additional layer of intermediate children that specify the drawing method otherwise encoded as a single case-sensitive letter inside itsd
attribute. Making its compactd
notation more readable and editable is the main motivation for this issue.The text was updated successfully, but these errors were encountered: