Skip to content

Commit

Permalink
feat: SDD: Delimited blocks (#157)
Browse files Browse the repository at this point in the history
Discovered and fixed a new edge case around leading/trailing blank lines.
  • Loading branch information
scouten authored Nov 24, 2024
1 parent fa4f5f5 commit 26d8ff9
Show file tree
Hide file tree
Showing 3 changed files with 534 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/blocks/raw_delimited.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ impl<'src> RawDelimitedBlock<'src> {
}

let mut lines: Vec<Span<'src>> = vec![];
let mut next = delimiter.after;
let mut empty_lines: Vec<Span<'src>> = vec![];
let mut next = delimiter.after.discard_empty_lines();

while !next.is_empty() {
// TO DO: Should we retain trailing white space when in Raw content model?
Expand All @@ -94,7 +95,13 @@ impl<'src> RawDelimitedBlock<'src> {
});
}

lines.push(line.item);
if line.item.is_empty() {
empty_lines.push(line.item);
} else {
lines.append(&mut empty_lines);
lines.push(line.item);
}

next = line.after;
}

Expand Down
Loading

0 comments on commit 26d8ff9

Please sign in to comment.