vexy-vsvg 2.2.0

Core library for vexy-vsvg SVG optimizer
docs.rs failed to build vexy-vsvg-2.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: vexy-vsvg-0.1.0

Vexy VSVG

The engine room of Vexy.

Programmatic access to the Vexy SVG optimizer. Parse, traverse, optimize, and stringify SVGs with extreme prejudice against whitespace and redundancy.

Core Concepts

  • Parsing: Uses roxmltree and quick-xml to build a mutable AST.
  • Plugins: 50+ optimization strategies that operate on the AST.
  • Optimization: A pipeline that applies enabled plugins in order (multipass supported).
  • Stringification: Serializes the AST back to standard SVG XML.

Usage

Add this to your Cargo.toml:

[dependencies]
vexy-vsvg = "2.1.1"

Optimize an SVG string with default settings:

use vexy_vsvg::{optimize_default, VexyError};

fn main() -> Result<(), VexyError> {
    let svg = r#"<svg><rect width="100" height="100"/></svg>"#;
    let result = optimize_default(svg)?;
    
    println!("Optimized: {}", result.data);
    Ok(())
}

Configure specific plugins:

use vexy_vsvg::{optimize, Config, PluginConfig};

let mut config = Config::default();
config.plugins.push(PluginConfig::Name("removeDimensions".to_string()));

let svg = r#"<svg viewBox="0 0 10 10" width="10" height="10">...</svg>"#;
let result = optimize(svg, config.into()).unwrap();

Modules

  • ast: The Document Object Model (DOM) for SVG.
  • optimizer: The core optimization loop.
  • parser: From string to AST.
  • stringifier: From AST to string.
  • plugin_registry: Management of available plugins.