Module css_declaration_list

Source
Expand description

CSS Declaration List Parser

This module provides parsing and representation for CSS declaration lists (collections of property-value pairs typically found inside CSS rule blocks like { color: red; margin: 10px; padding: 5px !important }).

§Main API

  • CSSDeclarationList::from_string() - Parse a CSS declaration list from a string
  • CSSDeclarationList::new() - Create a new declaration list programmatically
  • remove_declaration() - Remove declarations by property name
  • Display trait implementation for converting back to CSS string

§Examples

use css_structs::CSSDeclarationList;
 
// Parse from string
let list = CSSDeclarationList::from_string("color: red; margin: 10px; padding: 5px").unwrap();
assert_eq!(list.declarations.len(), 3);

// Create and modify programmatically  
let mut list = CSSDeclarationList::from_string("color: red; margin: 10px").unwrap();
list.remove_declaration("color");
println!("{}", list); // "margin: 10px;"

// Create a new empty declaration list
let empty_list = CSSDeclarationList::new();
assert!(empty_list.declarations.is_empty());

Structs§

CSSDeclarationList