Skip to main content

parse_block_contents

Function parse_block_contents 

Source
pub fn parse_block_contents(css: &str) -> BlockContents<'_>
Expand description

Parse a block’s contents: declarations, at-rules and nested style rules, in order, the way a style rule’s {} block holds them since CSS Nesting. SimpleBlock::contents does the same for a parsed block.

use parsec_css::Item;

let block = parsec_css::parse_block_contents("color: red; &:hover { color: blue }");
assert!(matches!(&block.items[0], Item::Declaration(d) if d.name == "color"));
assert!(matches!(&block.items[1], Item::Rule(_)));