diff --git a/crates/swc_html_minifier/tests/fixture/text/input.html b/crates/swc_html_minifier/tests/fixture/text/input.html new file mode 100644 index 00000000000..8731e24be0e --- /dev/null +++ b/crates/swc_html_minifier/tests/fixture/text/input.html @@ -0,0 +1,33 @@ + + + + Document + + + +
Test
+
Test
+
Test
+
Test
+
Test
+
Test
+ +
Registered Trademark Symbol:
+ +
HTML Entities demo:
+ +

®

+

©

+

©

+ +

This Registered Trademark is a Script used in HTML document.

+ +
I want to display <br> tag
+ +
I want to display <i> tag
+ +
The cent sign: ¢
+
The cent sign: ¢
+ + + \ No newline at end of file diff --git a/crates/swc_html_minifier/tests/fixture/text/output.min.html b/crates/swc_html_minifier/tests/fixture/text/output.min.html new file mode 100644 index 00000000000..d6df92e3f7e --- /dev/null +++ b/crates/swc_html_minifier/tests/fixture/text/output.min.html @@ -0,0 +1,31 @@ + + Document + + + +
Test
+
Test
+
Test
+
Test
+
Test
+
Test
+ +
Registered Trademark Symbol:
+ +
HTML Entities demo:
+ +

®

+

©

+

©

+ +

This Registered Trademark is a Script used in HTML document.

+ +
I want to display <br> tag
+ +
I want to display <i> tag
+ +
The cent sign: ¢
+
The cent sign: ¢
+ + + diff --git a/crates/swc_html_parser/src/lexer/mod.rs b/crates/swc_html_parser/src/lexer/mod.rs index c7973387cb0..b94b4bf749f 100644 --- a/crates/swc_html_parser/src/lexer/mod.rs +++ b/crates/swc_html_parser/src/lexer/mod.rs @@ -5073,13 +5073,12 @@ where if let Some(found_entity) = found_entity { cur_pos = Some(self.input.cur_pos()); - entity = Some(found_entity); } // We stop when: // - not ascii alphabetic - // - we consume more characters them the longest entity + // - we consume more characters than the longest entity if !c.is_ascii_alphabetic() || temporary_buffer.len() > 33 { if let Some(cur_pos) = cur_pos { self.input.reset_to(cur_pos); @@ -5138,7 +5137,7 @@ where // Flush code points consumed as a character reference. Switch to the // return state. else { - if is_last_semicolon { + if !is_last_semicolon { self.emit_error(ErrorKind::MissingSemicolonAfterCharacterReference); }