1 | /*! |
2 | *svgtypes* is a collection of parsers for [SVG](https://www.w3.org/TR/SVG2/) types. |
3 | |
4 | ## Supported SVG types |
5 | |
6 | - [`<color>`](https://www.w3.org/TR/css-color-3/) |
7 | - [`<number>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGNumber) |
8 | - [`<length>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGLength) |
9 | - [`<angle>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGAngle) |
10 | - [`<viewBox>`](https://www.w3.org/TR/SVG2/coords.html#ViewBoxAttribute) |
11 | - [`<path>`](https://www.w3.org/TR/SVG2/paths.html#PathData) |
12 | - [`<transform>`](https://www.w3.org/TR/SVG11/types.html#DataTypeTransformList) |
13 | - [`<list-of-numbers>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGNumberList) |
14 | - [`<list-of-lengths>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGLengthList) |
15 | - [`<list-of-points>`](https://www.w3.org/TR/SVG11/shapes.html#PointsBNF) |
16 | - [`<filter-value-list>`](https://www.w3.org/TR/filter-effects-1/#typedef-filter-value-list) |
17 | - [`<paint>`](https://www.w3.org/TR/SVG2/painting.html#SpecifyingPaint) |
18 | - [`<preserveAspectRatio>`](https://www.w3.org/TR/SVG11/coords.html#PreserveAspectRatioAttribute) |
19 | - [`<enable-background>`](https://www.w3.org/TR/SVG11/filters.html#EnableBackgroundProperty) |
20 | - [`<IRI>`](https://www.w3.org/TR/SVG11/types.html#DataTypeIRI) |
21 | - [`<FuncIRI>`](https://www.w3.org/TR/SVG11/types.html#DataTypeFuncIRI) |
22 | - [`paint-order`](https://www.w3.org/TR/SVG2/painting.html#PaintOrder) |
23 | |
24 | ## Features |
25 | |
26 | - Complete support of paths, so data like `M10-20A5.5.3-4 110-.1` will be parsed correctly. |
27 | - Implicit path commands will be automatically converted into explicit one. |
28 | - Some SVG2 data types support. |
29 | - Pretty fast. |
30 | |
31 | ## Limitations |
32 | |
33 | - Accepts only [normalized](https://www.w3.org/TR/REC-xml/#AVNormalize) values, |
34 | e.g. an input text should not contain ` ` or `&data;`. |
35 | - All keywords must be lowercase. |
36 | Case-insensitive parsing is supported only for colors (requires allocation for named colors). |
37 | - The `<color>` followed by the `<icccolor>` is not supported. As the `<icccolor>` itself. |
38 | - [System colors](https://www.w3.org/TR/css3-color/#css2-system), like `fill="AppWorkspace"`, |
39 | are not supported. They were deprecated anyway. |
40 | |
41 | ## Safety |
42 | |
43 | - The library should not panic. Any panic considered as a critical bug and should be reported. |
44 | - The library forbids unsafe code. |
45 | |
46 | ## Alternatives |
47 | |
48 | None. |
49 | */ |
50 | |
51 | #![forbid (unsafe_code)] |
52 | #![deny (missing_docs)] |
53 | #![deny (missing_debug_implementations)] |
54 | #![deny (missing_copy_implementations)] |
55 | |
56 | macro_rules! matches { |
57 | ($expression:expr, $($pattern:tt)+) => { |
58 | match $expression { |
59 | $($pattern)+ => true, |
60 | _ => false |
61 | } |
62 | } |
63 | } |
64 | |
65 | mod angle; |
66 | mod aspect_ratio; |
67 | mod color; |
68 | #[rustfmt::skip] mod colors; |
69 | mod directional_position; |
70 | mod enable_background; |
71 | mod error; |
72 | mod filter_functions; |
73 | mod font; |
74 | mod funciri; |
75 | mod length; |
76 | mod number; |
77 | mod paint; |
78 | mod paint_order; |
79 | mod path; |
80 | mod points; |
81 | mod stream; |
82 | mod transform; |
83 | mod transform_origin; |
84 | mod viewbox; |
85 | |
86 | use crate::stream::{ByteExt, Stream}; |
87 | |
88 | pub use crate::angle::*; |
89 | pub use crate::aspect_ratio::*; |
90 | pub use crate::color::*; |
91 | pub use crate::directional_position::*; |
92 | pub use crate::enable_background::*; |
93 | pub use crate::error::*; |
94 | pub use crate::filter_functions::*; |
95 | pub use crate::font::*; |
96 | pub use crate::funciri::*; |
97 | pub use crate::length::*; |
98 | pub use crate::number::*; |
99 | pub use crate::paint::*; |
100 | pub use crate::paint_order::*; |
101 | pub use crate::path::*; |
102 | pub use crate::points::*; |
103 | pub use crate::transform::*; |
104 | pub use crate::transform_origin::*; |
105 | pub use crate::viewbox::*; |
106 | |