Crate svgparser [−] [src]
libsvgparser is a pull-based parser 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.
Supported SVG types
- <color>
- <paint>
- <path>
- <number> and <list-of-numbers>
- <length> and <list-of-lengths>
- <coordinate>
- <IRI>
- <FuncIRI>
- <transform-list>
- <style>
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-.1
will 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 supported only for color names. 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
style
attribute. - System colors, like
fill="AppWorkspace"
, are not supported. - There is no separate
opacity-value
type. It will be parsed as<number>
, but will be bound to 0..1 range. - Implicit path commands are not supported. All commands are parsed as explicit.
- Implicit MoveTo commands will be automatically converted into explicit LineTo.
Safety
- The library should not panic. Any panic considered as a critical bug and should be reported.
- The library forbids unsafe code.
Reexports
pub extern crate xmlparser; |
Modules
path |
Module for parsing |
style |
Module for parsing |
svg |
Module for parsing SVG structure. |
transform |
Module for parsing |
Structs
Color |
Representation of the |
Error |
The Error type. |
ErrorPos |
Position of the error. |
Length |
Representation of the |
LengthList |
Iterator over a list of |
NumberList |
Iterator over a list of |
StrSpan |
An immutable string slice. |
Stream |
Streaming text parsing interface. |
TextUnescape |
XML escaped text to plain text converter. |
Enums
AttributeId |
List of all SVG attributes. |
AttributeValue |
Representation of the SVG attribute value. |
ElementId |
List of all SVG elements. |
EntityDefinition |
Representation of the EntityDef value. |
ErrorKind |
The kind of an error. |
ExternalId |
Representation of the ExternalID value. |
LengthUnit |
List of all SVG length units. |
PaintFallback |
The paint type fallback value in case when |
ValueId |
List of values for presentation attributes. |
XmlSpace |
Spaces processing type. |
Traits
ChainedError |
This trait is implemented on all the errors generated by the |
ChainedErrorExt |
|
FromSpan |
A general tokenizer interface. |
StreamExt |
|