feat(parser): support multiple tables in a single markdown document
- Add extract_table_blocks() to split a document into contiguous table blocks, ignoring prose, headings, and blank lines between them - Add parse_document() as the new top-level entry point that runs extract_table_blocks + detect_has_duration_column + parse_table per block and returns a combined flat list of rows - Guard against empty End cells (e.g. in-progress rows) by validating the end field before calculating duration - Update cli.py to use parse_document() instead of the manual detect + parse combo - Add tests for extract_table_blocks and parse_document, including two smoke tests against the real 2026-W21 weekly timesheet file
This commit is contained in:
parent
7bea08ddac
commit
d6689a6c83
4 changed files with 295 additions and 9 deletions
|
|
@ -4,7 +4,7 @@ import sys
|
|||
from datetime import date
|
||||
|
||||
from .output import print_summary, write_csv
|
||||
from .parser import aggregate_rows, detect_has_duration_column, parse_table
|
||||
from .parser import aggregate_rows, parse_document
|
||||
from .projects import load_project_map
|
||||
from .utils import format_date
|
||||
|
||||
|
|
@ -18,7 +18,8 @@ def build_parser() -> argparse.ArgumentParser:
|
|||
help="Path to the markdown file containing the timesheet table, or '-' to read from stdin.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-o", "--output",
|
||||
"-o",
|
||||
"--output",
|
||||
help="Path to the output CSV file. Defaults to stdout.",
|
||||
default=None,
|
||||
)
|
||||
|
|
@ -59,7 +60,7 @@ def main() -> None:
|
|||
sys.exit(1)
|
||||
|
||||
lines = content.splitlines()
|
||||
rows = parse_table(lines, has_duration_col=detect_has_duration_column(lines))
|
||||
rows = parse_document(lines)
|
||||
|
||||
if not rows:
|
||||
print("Warning: no timesheet rows found in input.", file=sys.stderr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue