From a5a87dd553e1d4731432bb979e2c4dbf2baee6d7 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 23 Jul 2021 00:11:31 +0800 Subject: [PATCH] Fix to support format HTML comment, and void lose comment --- src/grammar/html.pest | 2 +- src/html.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/grammar/html.pest b/src/grammar/html.pest index d8f4f16d..67e55c41 100644 --- a/src/grammar/html.pest +++ b/src/grammar/html.pest @@ -22,7 +22,7 @@ doctype_name = @{ ^"doctype" } // NODES // node = _{ comment | node_element | text } -comment = _{ comment_if | comment_normal } +comment = { comment_if | comment_normal } text = { (!(chevron_left_normal | comment_tag_start ) ~ ANY)+ } // NOTE: Should we be able to write < in text? ^^ node_element = { el_void | el_void_xml | el_process_instruct | javascript_text | style_text | el_raw_text | el_normal | el_dangling } diff --git a/src/html.rs b/src/html.rs index b0b431ad..9a023342 100644 --- a/src/html.rs +++ b/src/html.rs @@ -50,6 +50,7 @@ mod tests { fn test_format_html() { let html = r###" + <%= title %>或者{{ title }}
@@ -86,6 +87,7 @@ mod tests { let expected = r###" + <%= title %>或者{{ title }}