libsvgparser
libsvgparser is a streaming parser/tokenizer for SVG 1.1 Full data format without heap allocations.
It's not an XML parser since it does not only split the content into the XML nodes, but also supports SVG types parsing.
Documentation
Supported SVG types
- <color>
- <paint>
- <path>
- <number> and <list-of-number>
- <length> and <list-of-length>
- <coordinate>
- <IRI>
- <FuncIRI>
- <transform-list>
- <style>
See the documentation for details.
Benefits
- Most of the common data parsed into internal representation, and not just as string (unlike typical XML parser). Tag names, attribute names, attributes value, etc.
- Complete support of paths, so data like
M10-20A5.5.3-4 110-.1will be parsed correctly. - Predefined SVG values for presentation attributes,
like
auto,normal,none,inherit, etc. are parsed asenum, not asString. - Every type can be parsed separately, so you can parse just paths or transform or any other SVG value.
- Good error processing. All error types contain position (line:column) where it occurred.
- No heap allocations.
- Pretty fast.
Limitations
- All keywords must be lowercase. Case-insensitive parsing is not supported. Still, it's extremely rare.
- The
<color>followed by the<icccolor>is not supported. As the<icccolor>itself. - Only ENTITY objects are parsed from the DOCTYPE. Other ignored.
- CSS styles does not processed. You should use an external CSS parser.
- Comments inside attributes value supported only for the
styleattribute. - User agent colors, aka
fill="AppWorkspace", is not supported. - There is no separate
opacity-valuetype. It will be parsed as<number>, but will be bound to 0..1 range. - An implicit path commands are not supported. All commands are parsed as explicit.
- An implicit MoveTo commands automatically converted to an explicit LineTo.
Differences between libsvgparser and SVG spec
<percentage>type is part of<length>type.
Usage
Add this to your Cargo.toml:
[]
= "0.0.3"
Roadmap
V0.1.0
- Parsing
f64from a string is pretty slow (Stream::parse_number). - Add an
fontattribute parsing support. - Add an
enable-backgroundattribute parsing support.
V0.2.0
- Add an
<angle>type support.
License
libsvgparser is licensed under the MPLv2.0.