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

Applied suggested fixes

This commit is contained in:
Cyberistic 2026-02-04 18:07:39 +03:00 committed by Matias Fontanini
parent c1be5e4964
commit 30933ed9c8
3 changed files with 7 additions and 19 deletions

View File

@ -157,7 +157,7 @@ be ignored during presentation rendering can be added using these formats:
```markdown
<!-- // This is a user comment -->
<!-- Comment: This is also a user comment which won't be rendered-->
<!-- comment: This is also a user comment which won't be rendered -->
```
These comments are completely invisible during presentation and useful for:
@ -235,4 +235,3 @@ endif
```
With this configuration, pressing `Ctrl+K` in insert mode will open an fzf picker with all available comment commands, allowing you to quickly select and insert them into your presentation.

View File

@ -5,9 +5,6 @@ author: Matias
Customizability
---
<!-- Comment: You can add comments like this that won't show up in the presentation -->
<!-- // This is another way to add comments! -->
_presenterm_ allows configuring almost anything about your presentation:
* The colors used.

View File

@ -44,6 +44,7 @@ impl PresentationBuilder<'_, '_> {
CommentCommand::NewLines(count) => {
self.push_line_breaks(count as usize * self.slide_font_size() as usize);
}
CommentCommand::Comment(_) => {}
CommentCommand::JumpToMiddle => self.chunk_operations.push(RenderOperation::JumpToVerticalCenter),
CommentCommand::InitColumnLayout(columns) => {
self.validate_column_layout(&columns, source_position)?;
@ -154,23 +155,14 @@ impl PresentationBuilder<'_, '_> {
if comment == "{{{" || comment == "}}}" {
return true;
}
// Ignore user comments with // prefix
// e.g., <!-- // This is a comment -->
let trimmed_comment = comment.trim_start_matches(&self.options.command_prefix).trim();
if trimmed_comment.starts_with("//") {
return true;
}
// Ignore user comments with Comment: prefix (case-insensitive)
// e.g., <!-- Comment: This is a comment -->
if trimmed_comment.len() >= 8 {
let prefix = &trimmed_comment[..8];
if prefix.eq_ignore_ascii_case("comment:") {
return true;
}
}
false
}
}
@ -227,6 +219,7 @@ pub(crate) enum CommentCommand {
SkipSlide,
SpeakerNote(String),
SnippetOutput(String),
Comment(String),
}
impl CommentCommand {
@ -312,6 +305,7 @@ mod tests {
#[case::incremental_lists("newlines: 2", CommentCommand::NewLines(2))]
#[case::incremental_lists("new_line", CommentCommand::NewLine)]
#[case::incremental_lists("newline", CommentCommand::NewLine)]
#[case::comment("comment: This is a user comment", CommentCommand::Comment("This is a user comment".into()))]
fn command_formatting(#[case] input: &str, #[case] expected: CommentCommand) {
let parsed: CommentCommand = input.parse().expect("deserialization failed");
assert_eq!(parsed, expected);
@ -325,9 +319,7 @@ mod tests {
#[case::padded_vim_command("vim: hi")]
#[case::double_slash("// This is a user comment")]
#[case::double_slash_padded(" // This is a padded comment ")]
#[case::comment_colon("Comment: This is a user comment")]
#[case::comment_colon_lowercase("comment: This is also a user comment")]
#[case::comment_colon_mixedcase("CoMmEnT: Mixed case comment")]
#[case::comment_colon("comment: This is a user comment")]
fn ignore_comments(#[case] comment: &str) {
let input = format!("<!-- {comment} -->");
Test::new(input).build();