use-svg 0.0.1

Practical SVG utility primitives
Documentation
  • Coverage
  • 1.43%
    1 out of 70 items documented1 out of 44 items with examples
  • Size
  • Source code size: 32.81 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 991.14 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Documentation
  • RustUse/use-media
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • CloudBranch

use-svg

Practical SVG utility primitives for inspection, extraction, normalization, minification, and lightweight document construction.

Warning: use-svg is experimental and may change before 0.3.0.

Example

use use_svg::{SvgPath, build_svg_icon, extract_path_data, extract_view_box};

let source = r#"<svg viewBox="0 0 24 24"><path d="M3 3h18v18H3z"/></svg>"#;
let view_box = extract_view_box(source).unwrap();
let paths = extract_path_data(source);

assert_eq!(paths, vec!["M3 3h18v18H3z".to_string()]);

let icon = build_svg_icon(view_box, &[SvgPath::new("M3 3h18v18H3z")]);
assert!(icon.starts_with("<svg "));

Scope

  • SVG document detection and root extraction
  • Width, height, and SVG size extraction
  • viewBox parsing and formatting
  • SVG element and attribute helpers
  • Path data extraction helpers
  • Fill, stroke, and transform attribute helpers
  • Metadata extraction for common title and description tags
  • Basic normalization and minification
  • Simple SVG document and icon construction

Non-goals

  • A full SVG rendering engine
  • A full XML parser or DOM implementation
  • A complete SVG specification parser
  • CSS layout or browser compatibility behavior
  • Heavy dependency-driven parsing pipelines

License

Licensed under either the MIT license or the Apache License, Version 2.0, at your option.