Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mrml-core): comments in mrml component should be ignored #477

Merged
merged 2 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/mrml-core/src/mjml/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ impl<'opts> ParseChildren<MjmlChildren> for MrmlParser<'opts> {
cursor.rewind(MrmlToken::ElementClose(close));
return Ok(children);
}
MrmlToken::Text(inner) if inner.text.trim().is_empty() => {
// ignoring empty text
}
MrmlToken::Comment(_) => {
// ignoring comment on purpose
}
MrmlToken::ElementStart(start) => match start.local.as_str() {
MJ_HEAD => {
children.head = Some(self.parse(cursor, start.local)?);
Expand Down
13 changes: 13 additions & 0 deletions packages/mrml-core/tests/issue-474.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![cfg(feature = "parse")]

#[test]
fn should_preserve_comment() {
let template = r#"<mjml>
<mj-head>
</mj-head>
<mj-body>
</mj-body> <!-- Here -->
</mjml>"#;

let _root = mrml::parse(template).unwrap();
}
Loading