From 3c4b71612e1bcb9ff9f00f32ebc9f3b262daf67c Mon Sep 17 00:00:00 2001 From: Wilson Lin Date: Sat, 18 Jan 2020 22:39:33 +1100 Subject: [PATCH] Fix text minification --- src/proc.rs | 1 - src/unit/content.rs | 12 ++++++++---- src/unit/tag.rs | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/proc.rs b/src/proc.rs index f152068..0bede34 100644 --- a/src/proc.rs +++ b/src/proc.rs @@ -543,7 +543,6 @@ impl<'d> Processor<'d> { uep.state = UnintentionalEntityState::Ended; } pub fn suspend(&mut self, uep: &mut UnintentionalEntityPrevention) -> () { - debug_assert!(uep.state != UnintentionalEntityState::Ended); if uep.state != UnintentionalEntityState::Suspended { self._after_write(uep, true); uep.state = UnintentionalEntityState::Suspended; diff --git a/src/unit/content.rs b/src/unit/content.rs index f1861d3..cc13b36 100644 --- a/src/unit/content.rs +++ b/src/unit/content.rs @@ -24,8 +24,9 @@ enum ContentType { impl ContentType { fn is_tag_like(&self) -> bool { + // Do not include Comment as comments are not written. match self { - ContentType::Comment | ContentType::Bang | ContentType::Instruction | ContentType::Tag => true, + ContentType::Bang | ContentType::Instruction | ContentType::Tag => true, _ => false, } } @@ -159,9 +160,9 @@ pub fn process_content(proc: &mut Processor, parent: Option) -> uep.expect_active(); match entity { // TODO Comment: Explain why < is handled this way. - Some(e @ EntityType::NonDecodableRightChevron(_)) => { + Some(entity @ EntityType::NonDecodableRightChevron(_)) => { proc.suspend(uep); - e.keep(proc); + entity.keep(proc); proc.resume(uep); } Some(entity) => { @@ -179,7 +180,10 @@ pub fn process_content(proc: &mut Processor, parent: Option) -> } }; - last_written = next_content_type; + // Comments are discarded. + if next_content_type != ContentType::Comment { + last_written = next_content_type; + }; }; Ok(()) diff --git a/src/unit/tag.rs b/src/unit/tag.rs index f623b42..3ad1383 100644 --- a/src/unit/tag.rs +++ b/src/unit/tag.rs @@ -52,7 +52,7 @@ impl MaybeClosingTag { pub fn write(&mut self, proc: &mut Processor) -> () { proc.write_slice(b"'); }