Re: [svgwg] Relax SVG Path grammar with an implicite first MoveTo command (#780)

I actually do this in python `svgelements` module. Which follows a fairly reasonable implementation. Each command is given an object associated with it. Generally `Move`, `Line`, `CubicBezier`, `QuadBezier`, `Arc`, `Close` are the needed elements to properly implement `Path` objects which are collections of such objects. It's entirely reasonable to have a `QuadBezier` as a object with or without an initial move. And the logic is quite consistent. Every object has a starting position and every object has an ending position. All objects have an implied starting position including `Move`. 

Move itself can also be moved from any position to another position.  And when specifying a fragment they will often have an implicit starting position. An object defining a line from 7,7 to 10,0 would actually print as `M7,7L10,0` even though it's actually just a single path fragment.

Consequently I can pretty easily do that combination stuff:
`Path('"M0,50 V0 H100 V50') + "C100,100 0,0 0,50" + "z"` is perfectly logical and parses correctly.

But, I would strongly object to shadow dom like implied use objects like that. First, it'll wreck havoc on parsers. I mean your tag there has at least 3 commands in it (and strictly speaking everything is supposed to stop trying once it sees that # there which is invalid, and the z would never be seen so this is actually a breaking change.

Part of the charm of the path stuff within SVG is that it's generally highly useful on it's own. Even without all the svg stuff around it, plenty of things just parse paths and save them out. Messing with that seems like a pain. Do I really need to implement a whole shadow dom path fragment thing if I'm only parsing things to find <path> objects and then extract their strings which a lot of naive parsers will totally do?

And I can't really conclude there's going to be some path segments that are wildly reusable at the the subpath level. If you have a subpath, you're better off just having that subpath element stand alone and reusing that. 

-- 
GitHub Notification of comment by tatarize
Please view or discuss this issue at https://github.com/w3c/svgwg/issues/780#issuecomment-602647141 using your GitHub account

Received on Monday, 23 March 2020 14:51:11 UTC