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