$ show cwyalpha/Word-Formatter-Pro
Word-Formatter-Pro is a cross-platform desktop application and CLI tool for automatically formatting Word documents (.docx, .doc, .wps, .txt, .md) into a consistent Chinese government/official document style. It is built with Python, uses Tkinter for the GUI, python-docx for document manipulation, and integrates with WPS/Word COM on Windows or LibreOffice on macOS/Linux for legacy format conversion. The application features intelligent detection of headings (four levels), title/subtitle, figure/table captions, attachments, and can perform conservative symbol normalization, table auto-formatting, and blank line compression for text sources. The architecture is well-separated: a core formatting engine independent of GUI, a CLI interface, a configuration module, and a bundled Agent Skill. The code is actively maintained, with regular version releases and built-in unit tests covering critical logic.
The LLM identified 4 files worth highlighting for reuse:
The SofficeConverter class provides a clean, isolated adapter for converting legacy .doc/.wps files to .docx using LibreOffice. It handles finding the soffice executable, running the conversion with proper temporary directories and timeout, and cleaning up. This component is self-contained (no internal dependencies beyond subprocess/python-docx) and could be extracted and reused in any Python project needing headless LibreOffice conversion.
The static methods _normalize_symbols_in_text and related helpers implement conservative Chinese punctuation normalization. They handle bracket pairs, quote pairs, ellipsis, and simple punctuation replacements while intelligently avoiding changes in numeric/latin contexts. The logic is well-structured, uses regex precompilation, and is clearly separated from the core formatting flow. This component is reusable for any Chinese text normalization task.
The table helper methods (_normalize_table_pcts, _set_table_col_widths_by_content, _is_numeric_table_text, _is_short_table_text) implement a content-aware column width adjustment algorithm. They compute text weights, normalize percentages with min/max constraints, and set column widths accordingly. The smart alignment logic further adjusts paragraph alignment based on content type (numeric, short, header). This demonstrates non-obvious data engineering skill for dynamic table layout.
The _clean_markdown static method provides a thorough Markdown-to-plain-text conversion with careful handling of ordered list numbering preservation. It removes images, links, HTML, inline code markers, bold/italic markers, headings, blockquotes, horizontal rules, and unordered list markers while keeping original numeric ordering intact. This is a well-engineered ETL step that could be reused in any text processing pipeline.