parse_path
Parses SVG path data (the d attribute) into commands, as written: the letters keep their
case (absolute or relative), H/V/S/T/A stay what they are, and a command repeated
without its letter (L 1 2 3 4) becomes one command per set of numbers (M repeats as L,
m as l).
It follows the SVG grammar: numbers may be glued (1-2, .5.5, 1e-3), separators are
optional, and the two arc flags may be written without any separator (a1 1 0 011 1).
Import
Section titled “Import”Cargo feature geometry (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
d | &str | The path data. |
Returns
Section titled “Returns”Result<Vec<PathCommand>, ParsePathError> — The commands, in order. Empty for an empty or blank string.
Errors
Section titled “Errors”A ParsePathError if the data does not start with a move, has an unknown letter, or misses
numbers or flags.
Examples
Section titled “Examples”Error type: ParsePathError
Section titled “Error type: ParsePathError”Why SVG path data could not be parsed.
