Repository navigation
Conversation
docx_to_markdown wrote every paragraph first and appended all tables at the end, so a table lost the heading it belongs to. Paragraph.text also drops tracked insertions, content controls, fields and text boxes. And a cell's text went into its markdown row as is, so a line break split the row and a pipe added a column. Walk the body in document order, read each paragraph's runs inside those containers (skipping deleted text and the fallback copy of a text box), and put a cell on one line with its pipes escaped.
There was a problem hiding this comment.
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify review — findings
Rewrites docx_to_markdown to walk the document body in order via _docx_blocks so tables stay under the headings they follow, instead of appending all tables after all paragraphs. Reads paragraph text through _docx_paragraph_text, which pulls run-level text (t, tab, br, etc.) while skipping tracked deletions, moved-from text, ruby guides, and text-box fallback copies, and looks through content controls/custom XML wrappers; text boxes render as their own paragraphs after the paragraph that hosts them. Renders table cells with _docx_cell_markdown, collapsing each cell to a single pipe-escaped line and flattening nested tables into their cell, and adds tests/test_docx_to_markdown.py covering headings, ordering, cell escaping, nesting, tracked changes, and text boxes.
No blocking issues surfaced. 4 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 2464 functions depend on the 139 functions this change touches.
Health — this change adds coupling hotspots:
- new:
extract()— 703 callers, 47 callees - new:
_rebuild_code()— 144 callers, 55 callees - new:
detect()— 112 callers, 15 callees - new:
_extract_generic()— 18 callers, 29 callees - new:
save_manifest()— 40 callers, 11 callees - new:
extract_js()— 87 callers, 4 callees - new:
extract_files_direct()— 17 callers, 20 callees - new:
extract_xaml()— 19 callers, 17 callees - …and 50 more — each is listed as a finding
Verification — 2464 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 823 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
57 of 301 test file(s) selected (19%) via static blast radius.
tests/test_astro_extraction.py— impacttests/test_atomic_writes.py— impacttests/test_build.py— impacttests/test_cargo_introspect.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_cjs_module_extension.py— impacttests/test_claude_cli_backend.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_detect.py— impacttests/test_docx_to_markdown.py— impact, changed-testtests/test_dotnet.py— impacttests/test_evidence_binding.py— impacttests/test_extract.py— impacttests/test_extract_cli.py— impacttests/test_extract_php_closures.py— impacttests/test_file_slice.py— impacttests/test_ignore_file_encoding.py— impacttests/test_image_vision.py— impacttests/test_import_extension_resolution.py— impacttests/test_incremental_mtime_collision.py— impacttests/test_indirect_call_block_scoped_shadow.py— impacttests/test_indirect_dispatch.py— impacttests/test_indirect_dispatch_assign_return.py— impacttests/test_indirect_dispatch_getattr.py— impacttests/test_js_exported_scalar_bindings.py— impacttests/test_languages.py— impacttests/test_llm_backends.py— impacttests/test_long_path_hashing.py— impacttests/test_manifest_ingest.py— impacttests/test_mcp_ingest.py— impacttests/test_multilang.py— impacttests/test_non_regular_files.py— impacttests/test_office_incremental.py— impacttests/test_office_limits.py— impacttests/test_ollama.py— impacttests/test_out_dir_evidence.py— impacttests/test_oversized_document_slicing.py— impacttests/test_package_json_subpath_imports.py— impacttests/test_pdf_slicing.py— impacttests/test_pdf_token_estimate.py— impacttests/test_phantom_external_import.py— impacttests/test_pipeline.py— impacttests/test_python_underscore_resolution.py— impacttests/test_rationale.py— impacttests/test_ruby_resolution.py— impacttests/test_scala_self_type.py— impacttests/test_stale_prune.py— impacttests/test_swift_computed_properties.py— impacttests/test_swift_protocol_requirements.py— impact- … and 7 more
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
· 1 grounded finding(s) anchored inline below; 57 more finding(s) on lines outside this diff (see the check run).
| return " ".join(" ".join(part.split()) for part in parts if part.strip()).replace("|", "\\|") | ||
|
|
||
|
|
||
| def docx_to_markdown(path: Path) -> str: |
There was a problem hiding this comment.
docx_to_markdown()
high coupling complexity (Ca·Ce = 20).
Grounded coupling-delta finding (deterministic), not an LLM guess.
Atomic label sidecars (#3853), docx table/all-text extraction (#3833), wiki index-collision (#3818) and escaped wikilink aliases (#3772), community-listing real-node filter (#3836), warn-once on missing pypdf extra (#3710), plus the --help logo banner + app.graphify.com line. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Shipped in v0.9.72 (now on PyPI) via an authorship-preserving cherry-pick, so your commit keeps contributor-graph credit. Thanks @L4XB! docx sidecar conversion keeps tables in place and reads all text. |
What does this PR do?
graphify.detect.docx_to_markdownwrites the markdown sidecar that a.docxfile is extracted from. It had three problems:Paragraph.textreads only the runs directly under a paragraph. So tracked insertions (w:ins), content controls (w:sdt, which is how forms and templates hold their values), simple fields, smart tags and text boxes were dropped.|in a cell added a column.One document, before and after:
The document has the table under
# Pricing, a tracked change (tendeleted,twelveinserted), a content control holdingAcme, and a text boxCallout.The change:
docx_to_markdownwalksdoc.element.bodyin document order. A table is written where it stands, in the same header / separator / rows form as before, and python-docx'srow.cellsstill keeps merged cells aligned to the grid._docx_paragraph_textreads the text of every run in the paragraph. It skips runs under a tracked deletion, moved-away text, a ruby guide, a text box, or themc:Fallbackcopy Word writes of each text box. A text box's paragraphs follow the paragraph that anchors it, once._docx_cell_markdownputs a cell on one line (line breaks and paragraphs become spaces), flattens a nested table into the cell once, and escapes|as\|.Headings, list items, plain and empty paragraphs are written exactly as before.
Type of change
How was this tested?
tests/test_docx_to_markdown.pyis new, with 5 tests on real.docxfiles built with python-docx:4 of the 5 fail on
v8; the one that passes is the plain-paragraph test, which pins that the output did not change there. Each of 9 mutants of the new code is caught by a failing test: tables dropped, pipes not escaped, cell whitespace kept, deletions read, text box runs read inline, fallback copy read, text boxes not emitted, content controls skipped, nested table dropped.Graphify-specific checklist