diff --git a/docs/plans/2026-07-27-md2doc.md b/docs/plans/2026-07-27-md2doc.md new file mode 100644 index 0000000..c55e290 --- /dev/null +++ b/docs/plans/2026-07-27-md2doc.md @@ -0,0 +1,1888 @@ +# md2doc + md2pdf bugfixes Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use aws-subagent-driven-development (recommended) or aws-executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Build `md2doc.py` (Markdown→DOCX converter, python-docx based) and fix two md2pdf.py bugs (`--footer` dead in CLI, `--forms` non-functional). + +**Architecture:** Sibling single-file Python utility mirroring md2pdf.py structure (STYLES dict, COMMON rules, _bulletize logic copied). Manual XML manipulation for paragraph borders/shading and numbering. Pipeline: md text → `markdown.markdown()` → `BeautifulSoup` HTML walk → emit docx elements. + +**Tech Stack:** Python 3.x, `python-docx` (new dep), `markdown` (existing), `beautifulsoup4` (existing), `lxml` (new dep). + +## Research Summary + +### Existing Knowledge + +- **md2pdf.py patterns (existing in /Users/sebastian/projects/tools/md2pdf.py):** + - `STYLES` dict with 5 stiluri (elegant default, default, dark, mono, report) + - `COMMON_CSS` string injectat după stilul ales + - `_bulletize(text)` — transformă `- ` în `• ` dar nu în code/HTML blocuri + - `BLANK_MARKER` injection pentru multi-blank-line preservation + - `convert_md_to_pdf(md_file, output_file, style, forms, footer)` — main converter + - `main()` — argparse cu `input`, `-o/--output`, `--style`, `-q/--quiet`, `--forms` +- **Empirical findings from spec Stage 2 (doc:** `docs/specs/2026-07-27-md2doc-design.md`):** + - python-docx 1.2 nu are API pentru paragraph borders/shading — merge doar XML + - `paragraph.style = "List Bullet 2/3"` NU produce liste imbricate — necesită `w:abstractNum` multi-level + per-paragraph `w:numPr` cu `ilvl` + - weasyprint 68.1 silently drop ``/`