Skip to content

Commit

Permalink
Fix to support format HTML comment, and void lose comment
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Jul 22, 2021
1 parent d14b2fd commit a5a87dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/grammar/html.pest
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
2 changes: 2 additions & 0 deletions src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ mod tests {
fn test_format_html() {
let html = r###"
<!DOCTYPE html>
<!-- html的注释 -->
<html xmlns=http://www.w3.org/1999/xhtml>
<title><%= title %>或者{{ title }}</title>
<article>
Expand Down Expand Up @@ -86,6 +87,7 @@ mod tests {

let expected = r###"
<!DOCTYPE html>
<!-- html 的注释 -->
<html xmlns=http://www.w3.org/1999/xhtml>
<title><%= title %>或者{{ title }}</title>
<article>
Expand Down

0 comments on commit a5a87dd

Please sign in to comment.