Skip to content

Commit

Permalink
Merge pull request #167 from mfontanini/newline-command
Browse files Browse the repository at this point in the history
Add newlines command
  • Loading branch information
mfontanini authored Jan 24, 2024
2 parents c97041a + fb3371c commit f54dc1e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/processing/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ impl<'a> PresentationBuilder<'a> {
match comment {
CommentCommand::Pause => self.process_pause(),
CommentCommand::EndSlide => self.terminate_slide(),
CommentCommand::NewLine => self.push_line_break(),
CommentCommand::NewLines(count) => {
for _ in 0..count {
self.push_line_break();
}
}
CommentCommand::JumpToMiddle => self.chunk_operations.push(RenderOperation::JumpToVerticalCenter),
CommentCommand::InitColumnLayout(columns) => {
Self::validate_column_layout(&columns)?;
Expand Down Expand Up @@ -842,6 +848,10 @@ pub enum BuildError {
enum CommentCommand {
Pause,
EndSlide,
#[serde(alias = "newline")]
NewLine,
#[serde(alias = "newlines")]
NewLines(u32),
#[serde(rename = "column_layout")]
InitColumnLayout(Vec<u8>),
Column(usize),
Expand Down Expand Up @@ -1143,6 +1153,10 @@ mod test {
#[case::column("column: 1", CommentCommand::Column(1))]
#[case::reset_layout("reset_layout", CommentCommand::ResetLayout)]
#[case::incremental_lists("incremental_lists: true", CommentCommand::IncrementalLists(true))]
#[case::incremental_lists("new_lines: 2", CommentCommand::NewLines(2))]
#[case::incremental_lists("newlines: 2", CommentCommand::NewLines(2))]
#[case::incremental_lists("new_line", CommentCommand::NewLine)]
#[case::incremental_lists("newline", CommentCommand::NewLine)]
fn command_formatting(#[case] input: &str, #[case] expected: CommentCommand) {
let parsed: CommentCommand = input.parse().expect("deserialization failed");
assert_eq!(parsed, expected);
Expand Down

0 comments on commit f54dc1e

Please sign in to comment.