Fix text minification

This commit is contained in:
Wilson Lin 2020-01-18 22:39:33 +11:00
parent b88e96e97e
commit 3c4b71612e
3 changed files with 9 additions and 6 deletions

View File

@ -543,7 +543,6 @@ impl<'d> Processor<'d> {
uep.state = UnintentionalEntityState::Ended; uep.state = UnintentionalEntityState::Ended;
} }
pub fn suspend(&mut self, uep: &mut UnintentionalEntityPrevention) -> () { pub fn suspend(&mut self, uep: &mut UnintentionalEntityPrevention) -> () {
debug_assert!(uep.state != UnintentionalEntityState::Ended);
if uep.state != UnintentionalEntityState::Suspended { if uep.state != UnintentionalEntityState::Suspended {
self._after_write(uep, true); self._after_write(uep, true);
uep.state = UnintentionalEntityState::Suspended; uep.state = UnintentionalEntityState::Suspended;

View File

@ -24,8 +24,9 @@ enum ContentType {
impl ContentType { impl ContentType {
fn is_tag_like(&self) -> bool { fn is_tag_like(&self) -> bool {
// Do not include Comment as comments are not written.
match self { match self {
ContentType::Comment | ContentType::Bang | ContentType::Instruction | ContentType::Tag => true, ContentType::Bang | ContentType::Instruction | ContentType::Tag => true,
_ => false, _ => false,
} }
} }
@ -159,9 +160,9 @@ pub fn process_content(proc: &mut Processor, parent: Option<ProcessorRange>) ->
uep.expect_active(); uep.expect_active();
match entity { match entity {
// TODO Comment: Explain why < is handled this way. // TODO Comment: Explain why < is handled this way.
Some(e @ EntityType::NonDecodableRightChevron(_)) => { Some(entity @ EntityType::NonDecodableRightChevron(_)) => {
proc.suspend(uep); proc.suspend(uep);
e.keep(proc); entity.keep(proc);
proc.resume(uep); proc.resume(uep);
} }
Some(entity) => { Some(entity) => {
@ -179,7 +180,10 @@ pub fn process_content(proc: &mut Processor, parent: Option<ProcessorRange>) ->
} }
}; };
last_written = next_content_type; // Comments are discarded.
if next_content_type != ContentType::Comment {
last_written = next_content_type;
};
}; };
Ok(()) Ok(())

View File

@ -52,7 +52,7 @@ impl MaybeClosingTag {
pub fn write(&mut self, proc: &mut Processor) -> () { pub fn write(&mut self, proc: &mut Processor) -> () {
proc.write_slice(b"</"); proc.write_slice(b"</");
proc.write_range(self.0.unwrap()); proc.write_range(self.0.take().unwrap());
proc.write(b'>'); proc.write(b'>');
} }