5 ms·
SVG is very complex. This format is very simple because it is not supposed to solve a very complex problem. That makes it easier to write other viewers and ed
by Athas 4y ago
SVG is very complex. This format is very simple because it is not supposed to solve a very complex problem. That makes it easier to write other viewers and editors.
- mg 4y agoIt's not too complex. A line is just <line x1=10 y1=20 x2=30 y2=40>: https://jsfiddle.net/46q5srhg/ https://jsfiddle.net/46q5srhg/ It can also be used inside markdown, which supports it out of the box because SVG is part of HTML: https://markdownpastebin.com/?id=7d7b2f9dc65448ddbd7d1576676301a7 https://markdownpastebin.com/?id=7d7b2f9dc65448ddbd7d1576676...
- ainar-g 4y agoA subset of SVG with just basic lines and shapes is fairly simple, and in fact is very similar to what OP is doing. It's only when you go into colours, fonts, animations, and stuff like that stuff gets progressively more complex.
- cal85 4y agoI've often just wanted a "simple SVG" subset with just basics, as you describe, omitting all the fancy stuff that tends to lead to surprises and incompatibilities. For example, as the format for a very simple icon editor. Do you know if there is some formal way to 'declare' such a subset (something to do with XML/namespaces maybe?), or if there's any existing standard "simple SVG" format that someone has already defined? Obviously I could just informally stick to a subset by avoiding whatever features I don't want to use, but I think it would be useful to have a formally defined subset, and to be able to scan an SVG to detect if it's within the subset or not.
- ainar-g 4y agoThere's the SVG Tiny profile[1] which was created back in the day for the low-power mobile devices. Seems like a good start! [1]: https://www.w3.org/TR/SVGTiny/ https://www.w3.org/TR/SVGTiny/
- aendruk 4y agoAnd for a real world example of this see BIMI logo images.
- cal85 4y agoTried googling but can't find what you are referring to. Got a link?
- aendruk 4y agoBrand Indicators for Message Identification, part anti-phishing feature, part marketing gimmick. Essentially favicons for email. The Wikipedia article does the best job of summarizing it without marketing industry fluff: https://en.wikipedia.org/wiki/Brand_Indicators_for_Message_Identification https://en.wikipedia.org/wiki/Brand_Indicators_for_Message_I...
- deleted 4y ago[deleted]
- Athas 4y agoBut then it might easily become unclear exactly which subset of SVG is supported. I am personally leery of implementing subsets of other formats. I find it better to define entirely new formats, at least for simple things like this. To render this "lines" format, you could of course easily write a translator that turns it into SVG. It's mostly the other direction that I would be hesitant about.
- bestest 4y agoWhy would you want implement a subset of SVG? It's native for browsers, and is surely supported in a plethora of languages using various libraries.
- aidos 4y agoHmmm. There actually a lot to it and you don’t want to end up in a situation where documents don’t render properly unless you’re using a really complete viewer.
- cxcorp 4y agoBecause standards compliant SVG introduces XSS surfaces.
- badsectoracula 4y agoNow you replaced a trivial file format that (from a quick glance at the code) needed about ~35 of easily readable and self-contained Lua code to parse with an external dependency that would be much larger and harder to follow and either having (at least) an XML parser as its own dependency or implementing its own XML parsing, as well as being at the mercy of their developers. Also unless you are using some highly popular library, you may end up with some abandoned dependency. Examples of both are at [0] (C++ based parser, you'd also need to write some bindings for lua) and [1] (Lua based parser for a subset of the format, abandoned for almost a decade). There are times when using an external dependency might be a good idea, but a text-based file format that describes lines and can be implemented in a few lines of code is not one. [0] https://github.com/svgpp/svgpp https://github.com/svgpp/svgpp [1] https://github.com/luapower/svg_parser https://github.com/luapower/svg_parser
- speps 4y agoHe could have just used SVG path syntax which would have been a lot more compact that the current syntax. {"p2":{"x":141,"y":85},"mode":"line","p1":{"x":34,"y":44}} becomes M 34 44 L 141 85 and of course also has ways to express curved paths, etc.
- aidos 4y agoMy thoughts exactly. Svg path format is great and would fit nicely here.
- quickthrower2 4y agoYou can write simple svg but if you are interpreting all of svg it is not simple to write that code. Mozilla hasn’t successfully implemented it all properly for example.
- boondaburrah 4y agoJust like Abiword's document format doesn't cover all of HTML, but it is itself perfectly parseable as HTML, I don't think this editor has to.
- vidarh 4y agoThat's true, but they're explicitly suggesting SVG path syntax which is very simple. The downside is it's also very limited, and might well prove too limited for the author going forward.
- andsoitis 4y ago> Mozilla hasn’t successfully implemented it all properly for example. interesting. I didn't know that. I tried googling to find out what parts are not implemented but couldn't find anything (admittedly not a long search). Do you have more information you can point me to?
- quickthrower2 4y agoI found bugs in the position of text along a path using baseline etc. I need to dig up the code to find it.
- DemocracyFTW2 4y agoSVG in its entirety is of considerable complexity but its path data attribute syntax is fairly simple, well documented and optimized to be forgiving and compressed while still using nothing but a few ASCII letters, digits and plus and minus signs