Handle comments correctly

This commit is contained in:
Wilson Lin 2020-01-19 11:44:11 +11:00
parent 9f93a5d6de
commit 6b2b8cf552
7 changed files with 59 additions and 59 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -5,8 +5,8 @@
"relative": 1 "relative": 1
}, },
"hyperbuild-nodejs": { "hyperbuild-nodejs": {
"absolute": 353540, "absolute": 353498,
"relative": 0.9585809726259165 "relative": 0.9584670947030498
}, },
"html-minifier": { "html-minifier": {
"absolute": 355185, "absolute": 355185,
@ -23,8 +23,8 @@
"relative": 1 "relative": 1
}, },
"hyperbuild-nodejs": { "hyperbuild-nodejs": {
"absolute": 231718, "absolute": 231702,
"relative": 0.9411129207162787 "relative": 0.9410479373885637
}, },
"html-minifier": { "html-minifier": {
"absolute": 234306, "absolute": 234306,
@ -59,8 +59,8 @@
"relative": 1 "relative": 1
}, },
"hyperbuild-nodejs": { "hyperbuild-nodejs": {
"absolute": 270869, "absolute": 270827,
"relative": 0.8744987764010047 "relative": 0.8743631796785712
}, },
"html-minifier": { "html-minifier": {
"absolute": 277911, "absolute": 277911,
@ -77,8 +77,8 @@
"relative": 1 "relative": 1
}, },
"hyperbuild-nodejs": { "hyperbuild-nodejs": {
"absolute": 79807, "absolute": 79804,
"relative": 0.9430330387105922 "relative": 0.9429975894503001
}, },
"html-minifier": { "html-minifier": {
"absolute": 81446, "absolute": 81446,
@ -95,8 +95,8 @@
"relative": 1 "relative": 1
}, },
"hyperbuild-nodejs": { "hyperbuild-nodejs": {
"absolute": 5744290, "absolute": 5744286,
"relative": 0.9094262560459782 "relative": 0.9094256227727583
}, },
"html-minifier": { "html-minifier": {
"absolute": 5785725, "absolute": 5785725,
@ -203,8 +203,8 @@
"relative": 1 "relative": 1
}, },
"hyperbuild-nodejs": { "hyperbuild-nodejs": {
"absolute": 272478, "absolute": 272477,
"relative": 0.8645868369114782 "relative": 0.8645836638595734
}, },
"html-minifier": { "html-minifier": {
"absolute": 266639, "absolute": 266639,
@ -221,8 +221,8 @@
"relative": 1 "relative": 1
}, },
"hyperbuild-nodejs": { "hyperbuild-nodejs": {
"absolute": 1319434, "absolute": 1319430,
"relative": 0.9350028877054611 "relative": 0.9350000531479533
}, },
"html-minifier": { "html-minifier": {
"absolute": 1327244, "absolute": 1327244,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View File

@ -1,67 +1,67 @@
{ {
"Amazon": { "Amazon": {
"hyperbuild-nodejs": 502.24664208689205, "hyperbuild-nodejs": 497.0684008679241,
"html-minifier": 35.29094514423333, "html-minifier": 36.28930820880813,
"minimize": 115.65576358024069 "minimize": 114.18558697357896
}, },
"BBC": { "BBC": {
"hyperbuild-nodejs": 534.2273806686738, "hyperbuild-nodejs": 530.356838970197,
"html-minifier": 48.494203597533264, "html-minifier": 48.63263590575628,
"minimize": 162.19058006327936 "minimize": 160.9462295874063
}, },
"Bing": { "Bing": {
"hyperbuild-nodejs": 2140.7640403400474, "hyperbuild-nodejs": 2134.6747025695076,
"html-minifier": 219.51796458703646, "html-minifier": 221.00143110816123,
"minimize": 556.4985790478128 "minimize": 551.4842672816046
}, },
"Bootstrap": { "Bootstrap": {
"hyperbuild-nodejs": 281.194875239674, "hyperbuild-nodejs": 271.35337683063364,
"html-minifier": 7.8415099622038555, "html-minifier": 7.97192942546144,
"minimize": 22.529031134122878 "minimize": 22.302011949055192
}, },
"Coding Horror": { "Coding Horror": {
"hyperbuild-nodejs": 1047.0958113343395, "hyperbuild-nodejs": 1019.5233646175254,
"html-minifier": 47.42413048467408, "html-minifier": 49.28536290527941,
"minimize": 192.42462057036215 "minimize": 187.54666897520576
}, },
"ECMA-262": { "ECMA-262": {
"hyperbuild-nodejs": 15.772555656834477, "hyperbuild-nodejs": 15.344258383194457,
"html-minifier": 0.44192845474704334, "html-minifier": 0.44536511869011475,
"minimize": 1.3294991658715587 "minimize": 1.3342793943531839
}, },
"Google": { "Google": {
"hyperbuild-nodejs": 1835.2139045218082, "hyperbuild-nodejs": 1827.5416680815183,
"html-minifier": 241.2525641836837, "html-minifier": 242.58427545496446,
"minimize": 580.9205037326506 "minimize": 579.275465488081
}, },
"Hacker News": { "Hacker News": {
"hyperbuild-nodejs": 2078.0864684534695, "hyperbuild-nodejs": 2071.747702993173,
"html-minifier": 73.73992684219166, "html-minifier": 73.41021778919102,
"minimize": 275.23770113550273 "minimize": 270.4509347009959
}, },
"NY Times": { "NY Times": {
"hyperbuild-nodejs": 262.6791315524891, "hyperbuild-nodejs": 276.16242726823117,
"html-minifier": 37.21473163759241, "html-minifier": 36.853296596407354,
"minimize": 87.5459988860411 "minimize": 86.40323822747456
}, },
"Reddit": { "Reddit": {
"hyperbuild-nodejs": 392.33718670985326, "hyperbuild-nodejs": 404.3269179058215,
"html-minifier": 45.080090941207395, "html-minifier": 44.98344851074736,
"minimize": 126.02956065880237 "minimize": 124.11335556541236
}, },
"Stack Overflow": { "Stack Overflow": {
"hyperbuild-nodejs": 806.413713289417, "hyperbuild-nodejs": 820.8141564896657,
"html-minifier": 41.36174599511134, "html-minifier": 41.63919304297733,
"minimize": 161.42178263684914 "minimize": 161.27817560216315
}, },
"Twitter": { "Twitter": {
"hyperbuild-nodejs": 277.80868572702855, "hyperbuild-nodejs": 280.20971195021036,
"html-minifier": 37.062907987061436, "html-minifier": 37.298870434334766,
"minimize": 168.569458535333 "minimize": 166.8418036944524
}, },
"Wikipedia": { "Wikipedia": {
"hyperbuild-nodejs": 54.76838615471663, "hyperbuild-nodejs": 54.272192449450806,
"html-minifier": 2.7997721992329714, "html-minifier": 2.8349496354931727,
"minimize": 8.79398557057751 "minimize": 8.748906528012489
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 65 KiB

View File

@ -67,6 +67,11 @@ pub fn process_content(proc: &mut Processor, parent: Option<ProcessorRange>) ->
// Do not write anything until any previously ignored whitespace has been processed later. // Do not write anything until any previously ignored whitespace has been processed later.
let next_content_type = ContentType::peek(proc); let next_content_type = ContentType::peek(proc);
let entity: Option<EntityType> = match next_content_type { let entity: Option<EntityType> = match next_content_type {
ContentType::Comment => {
// Comments are completely ignored and do not affect anything (previous element node's closing tag, unintentional entities, whitespace, etc.).
process_comment(proc)?;
continue;
}
ContentType::Entity => Some(parse_entity(proc, false)?), ContentType::Entity => Some(parse_entity(proc, false)?),
_ => None, _ => None,
}; };
@ -108,11 +113,6 @@ pub fn process_content(proc: &mut Processor, parent: Option<ProcessorRange>) ->
// Process and consume next character(s). // Process and consume next character(s).
match next_content_type { match next_content_type {
ContentType::Comment => {
// Comments are completely ignored and do not affect anything (previous element node's closing tag, unintentional entities, whitespace, etc.).
process_comment(proc)?;
continue;
}
ContentType::Tag => { ContentType::Tag => {
proc.suspend(uep); proc.suspend(uep);
let new_closing_tag = process_tag( let new_closing_tag = process_tag(
@ -177,7 +177,7 @@ pub fn process_content(proc: &mut Processor, parent: Option<ProcessorRange>) ->
} }
}; };
// This should not be reached if ContentType::Comment. // This should not be reached if ContentType::{Comment, End}.
last_written = next_content_type; last_written = next_content_type;
}; };