forked from parcel-bundler/lightningcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom.rs
More file actions
36 lines (33 loc) · 961 Bytes
/
custom.rs
File metadata and controls
36 lines (33 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use cssparser::*;
#[derive(Debug, Clone, PartialEq)]
pub struct CustomProperty {
pub name: String,
pub value: String
}
impl CustomProperty {
pub fn parse<'i, 't>(
name: CowRcStr<'i>,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i, ()>> {
input.skip_whitespace();
input.parse_until_before(Delimiter::Bang | Delimiter::Semicolon, |input| {
// Need at least one token
let start = input.state();
input.next_including_whitespace()?;
input.reset(&start);
// parse_declaration_value_block(input, references, missing_closing_characters)
let start = input.position();
loop {
match input.next_including_whitespace_and_comments() {
Ok(_) => {},
Err(..) => {
return Ok(CustomProperty {
name: name.as_ref().into(),
value: input.slice_from(start).trim_end().into()
})
},
};
}
})
}
}