From 5f8c2bdbc25669e0289536dce3e31470bc32b48e Mon Sep 17 00:00:00 2001 From: Sebastian Petrescu Date: Mon, 27 Jul 2026 23:46:45 +0300 Subject: [PATCH] Plan: address Stage 1 reviewer feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: - Critical: add Task 1.5 (_bulletize copy with complete code) - Major: enrich STYLES dict (5 styles now visually distinct) - Major: implement COMMON dict partial (keep_with_next on headings) - Major: inline code now gets run-level shading (spec §4) - Minor: heading color assertion added - Minor: Task 5 Step 4.5 H3 keystone manual checkpoint (spec §4.2) - Minor: Task 8 exact line numbers from Research Summary - Minor: Task 10 renamed to characterization test --- docs/plans/2026-07-27-md2doc.md | 1888 +++++++++++++++++++++++++++++++ 1 file changed, 1888 insertions(+) create mode 100644 docs/plans/2026-07-27-md2doc.md 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 ``/`