fix(parser): allow blank lines within a table block
Blank (whitespace-only) lines inside a table no longer split it into separate blocks. They are buffered and discarded if more table rows follow, enabling patterns like pre-filling a recurring meeting entry with a blank line separating it from the rest of the day's entries.
This commit is contained in:
parent
ac1e9f959a
commit
d5dbe8791b
2 changed files with 54 additions and 5 deletions
|
|
@ -91,6 +91,45 @@ class TestExtractTableBlocks:
|
|||
blocks = extract_table_blocks(lines)
|
||||
assert len(blocks) == 1
|
||||
|
||||
def test_blank_line_within_table_kept_as_one_block(self):
|
||||
# A blank line in the middle of a table should not split it
|
||||
lines = [
|
||||
"| Start | End | Project | Story | Note |",
|
||||
"|-------|-------|---------|-------|------||",
|
||||
"| 08:00 | 08:30 | bugs | | |",
|
||||
"",
|
||||
"| 09:00 | 09:30 | scrum | | dsu |",
|
||||
]
|
||||
blocks = extract_table_blocks(lines)
|
||||
assert len(blocks) == 1
|
||||
assert len(blocks[0]) == 4 # header + sep + row + row (blank dropped)
|
||||
|
||||
def test_multiple_blank_lines_within_table(self):
|
||||
lines = [
|
||||
"| Start | End | Project | Story | Note |",
|
||||
"|-------|-------|---------|-------|------||",
|
||||
"| 08:00 | 08:30 | bugs | | |",
|
||||
"",
|
||||
"",
|
||||
"| 09:00 | 09:30 | scrum | | dsu |",
|
||||
]
|
||||
blocks = extract_table_blocks(lines)
|
||||
assert len(blocks) == 1
|
||||
assert len(blocks[0]) == 4
|
||||
|
||||
def test_blank_line_at_end_of_table_does_not_include_blank(self):
|
||||
# Blank after the last row should not be included in the block
|
||||
lines = WITH_DURATION + ["", "# Next section"]
|
||||
blocks = extract_table_blocks(lines)
|
||||
assert len(blocks) == 1
|
||||
assert "" not in blocks[0]
|
||||
|
||||
def test_blank_between_tables_still_splits(self):
|
||||
# A blank followed by prose should still end the first block
|
||||
lines = WITH_DURATION + ["", "# Next day", ""] + WITHOUT_DURATION
|
||||
blocks = extract_table_blocks(lines)
|
||||
assert len(blocks) == 2
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# parse_table
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue