Skip to content

Commit

Permalink
fix(mrml-core): make sure we can parse <mj-font></mj-font> (#359)
Browse files Browse the repository at this point in the history
Signed-off-by: Jérémie Drouet <jeremie.drouet@gmail.com>
  • Loading branch information
jdrouet authored Dec 19, 2023
1 parent ff1e392 commit 2f6027e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/mrml-core/src/mj_font/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn parse(cursor: &mut MrmlCursor<'_>) -> Result<MjFont, Error> {
let attributes = parse_attributes(cursor)?;
let ending = cursor.assert_element_end()?;
if !ending.empty {
return Err(Error::InvalidFormat(ending.span.into()));
cursor.assert_element_close()?;
}

Ok(MjFont { attributes })
Expand Down
30 changes: 30 additions & 0 deletions packages/mrml-core/tests/issue-356.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#![cfg(feature = "parse")]

#[test]
fn should_parse_mjfont() {
let template = r#"<mjml>
<mj-head>
<mj-font href="https://fonts.googleapis.com/css?family=Inter:normal&display=swap" name="Inter" />
<mj-font href="https://fonts.googleapis.com/css?family=Inter:bold&display=swap" name="InterBold">
</mj-font>
</mj-head>
<mj-body>
<div>Hello World</div>
</mj-body>
</mjml>"#;
let _ = mrml::parse(template).unwrap();
}

#[test]
fn should_parse_mjimage() {
let template = r#"<mjml>
<mj-body>
<div>Hello World</div>
<mj-image src="/other.png" />
<mj-image src="/wherever.png"> </mj-image>
<mj-image src="/wherever.png">
</mj-image>
</mj-body>
</mjml>"#;
let _ = mrml::parse(template).unwrap();
}

0 comments on commit 2f6027e

Please sign in to comment.