1
0
mirror of https://github.com/mfontanini/presenterm.git synced 2026-09-01 23:33:21 -06:00

Ignore multi-line comments

This commit is contained in:
Matias Fontanini 2023-10-14 10:06:13 -07:00
parent a1015733a7
commit b08468fe20
2 changed files with 6 additions and 2 deletions

View File

@ -216,6 +216,10 @@ impl<'a> PresentationBuilder<'a> {
}
fn process_comment(&mut self, comment: String) -> Result<(), BuildError> {
// Ignore any multi line comment; those are assumed to be user comments
if comment.contains('\n') {
return Ok(());
}
let comment = comment.parse::<CommentCommand>()?;
match comment {
CommentCommand::Pause => self.process_pause(),
@ -838,6 +842,7 @@ mod test {
#[rstest]
#[case::pause("pause", CommentCommand::Pause)]
#[case::pause(" pause ", CommentCommand::Pause)]
#[case::end_slide("end_slide", CommentCommand::EndSlide)]
#[case::column_layout("column_layout: [1, 2]", CommentCommand::InitColumnLayout(vec![1, 2]))]
#[case::column("column: 1", CommentCommand::Column(1))]

View File

@ -97,7 +97,6 @@ impl<'a> MarkdownParser<'a> {
}
let block = &block[start_tag.len()..];
let block = &block[0..block.len() - end_tag.len()];
let block = block.trim();
Ok(MarkdownElement::Comment(block.into()))
}
@ -674,7 +673,7 @@ let q = 42;
",
);
let MarkdownElement::Comment(text) = parsed else { panic!("not a comment: {parsed:?}") };
assert_eq!(text, "foo");
assert_eq!(text, " foo ");
}
#[test]