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): add missing comment parser for mj-head #374

Merged
merged 1 commit into from
Feb 24, 2024
Merged
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
12 changes: 12 additions & 0 deletions packages/mrml-core/src/mj_head/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ impl<'opts> ParseChildren<Vec<MjHeadChild>> for MrmlParser<'opts> {
let mut result = Vec::new();
loop {
match cursor.assert_next()? {
MrmlToken::Comment(inner) => {
result.push(MjHeadChild::Comment(crate::comment::Comment::from(
inner.text.as_str(),
)));
}
MrmlToken::ElementStart(inner) => {
result.push(self.parse(cursor, inner.local)?);
}
Expand Down Expand Up @@ -47,6 +52,11 @@ impl AsyncParseChildren<Vec<MjHeadChild>> for AsyncMrmlParser {
let mut result = Vec::new();
loop {
match cursor.assert_next()? {
MrmlToken::Comment(inner) => {
result.push(MjHeadChild::Comment(crate::comment::Comment::from(
inner.text.as_str(),
)));
}
MrmlToken::ElementStart(inner) => {
result.push(self.async_parse(cursor, inner.local).await?);
}
Expand Down Expand Up @@ -164,6 +174,8 @@ mod tests {
"<mj-head><mj-raw>Hello World!</mj-raw></mj-head>"
);

crate::should_parse!(with_comment, MjHead, "<mj-head><!-- HEAD --></mj-head>");

crate::should_not_parse!(
unexpected_element,
MjHead,
Expand Down
Loading