diff --git a/README.md b/README.md index 5e9d4b1..02ee794 100644 --- a/README.md +++ b/README.md @@ -296,11 +296,9 @@ Any entities in attribute values are decoded, and then the shortest representati - Single quoted, with any `'` encoded. - Unquoted, with `"`/`'` first character (if applicable), `>` last character (if applicable), and any whitespace encoded. -Some attributes have their whitespace (after any decoding) trimmed and collapsed: +`class` attributes have their whitespace (after any decoding) trimmed and collapsed. -- `class` - -[Boolean attributes](./gen/boolean_attrs.json) will have their values removed. +[Boolean attribute](./gen/boolean_attrs.json) values are removed. `type` attributes on `script` tags with a value equaling a [JavaScript MIME type](https://mimesniff.spec.whatwg.org/#javascript-mime-type) are removed. `type` attributes on `style` tags are removed. @@ -309,11 +307,16 @@ If an attribute value is empty after any processing, it is completely removed (i Spaces are removed between attributes if possible. +# Script and style + +Insignificant whitespace is trimmed and collapsed inside `. // TODO Optimise - while !chain!(proc.match_line_terminator().keep().matched()) { + while !chain!(proc.match_line_terminator().discard().matched()) { if chain!(proc.match_seq(b"").matched()) { break; } - proc.accept()?; + proc.skip()?; } Ok(()) @@ -28,19 +28,19 @@ fn parse_comment_single(proc: &mut Processor) -> ProcessingResult<()> { fn parse_comment_multi(proc: &mut Processor) -> ProcessingResult<()> { if cfg!(debug_assertions) { - chain!(proc.match_seq(b"/*").expect().keep()); + chain!(proc.match_seq(b"/*").expect().discard()); } else { - proc.accept_amount_expect(2); + proc.skip_amount_expect(2); }; // Comment can end at closing . // TODO Optimise - while !chain!(proc.match_seq(b"*/").keep().matched()) { + while !chain!(proc.match_seq(b"*/").discard().matched()) { if chain!(proc.match_seq(b"").matched()) { break; } - proc.accept()?; + proc.skip()?; }; Ok(()) diff --git a/src/unit/style.rs b/src/unit/style.rs index c91e884..de93006 100644 --- a/src/unit/style.rs +++ b/src/unit/style.rs @@ -11,14 +11,14 @@ fn is_string_delimiter(c: u8) -> bool { fn parse_comment(proc: &mut Processor) -> ProcessingResult<()> { if cfg!(debug_assertions) { - chain!(proc.match_seq(b"/*").expect().keep()); + chain!(proc.match_seq(b"/*").expect().discard()); } else { - proc.accept_amount_expect(2); + proc.skip_amount_expect(2); }; // Unlike script tags, style comments do NOT end at closing tag. - while !chain!(proc.match_seq(b"*/").keep().matched()) { - proc.accept()?; + while !chain!(proc.match_seq(b"*/").discard().matched()) { + proc.skip()?; }; Ok(())