Skip to content

Commit

Permalink
fix(trycmd): Allow empty code fences
Browse files Browse the repository at this point in the history
Fixes #190
  • Loading branch information
epage committed Jan 4, 2023
1 parent aaf9177 commit bb88ad3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ impl TryCmd {
let mut stdout_start;

if let Some((line_num, line)) = lines.pop_front() {
if let Some(raw) = line.strip_prefix("$ ") {
if line.starts_with(&fence_pattern) {
break;
} else if let Some(raw) = line.strip_prefix("$ ") {
cmdline.extend(shlex::Shlex::new(raw.trim()));
cmd_start = line_num;
stdout_start = line_num + 1;
Expand Down Expand Up @@ -772,6 +774,22 @@ mod test {
assert_eq!(expected, actual);
}

#[test]
fn parse_trycmd_empty_fence() {
let expected = TryCmd {
steps: vec![],
..Default::default()
};
let actual = TryCmd::parse_trycmd(
"
```
```
",
)
.unwrap();
assert_eq!(expected, actual);
}

#[test]
fn parse_trycmd_command() {
let expected = TryCmd {
Expand Down

0 comments on commit bb88ad3

Please sign in to comment.