| name | docx-table-styler |
| description | Convert Obsidian/Markdown to styled DOCX for Korean government proposals and research reports. Styles all tables with navy header, horizontal row alternation, content-proportional column widths, 10pt font, tight cell margins, vertical center alignment. Preserves embedded images. Hancom HWP compatible. Triggers on requests like "DOCX 테이블 스타일", "한글 보고서 표 꾸미기", "정부 제안서 포맷 DOCX", "export Obsidian to styled Word", "all tables styled", "proposal document formatting". |
DOCX Table Styler (Korean Government Report Preset)
When to use
Invoke when the user asks to:
- Convert a large Markdown document (especially Obsidian vault with
![[wikilinks]]) to a styled .docx
- Apply consistent branded table styling across many tables (dozens to hundreds)
- Produce a Korean government proposal, research report, or bilingual KR/EN document
- Prepare a DOCX that will later be opened in Hancom Office and saved as
.hwp/.hwpx
What it does
Full pipeline from source .md to styled .docx:
- Converts Obsidian
![[filename]] wikilinks to standard markdown links (sed preprocessing)
- Runs Pandoc to produce unstyled
.docx with TOC and embedded images
- Applies table styling via
python-docx to every table (including nested):
tblLook conditional formatting flags → zeroed (prevents style override)
- Content-proportional column widths (Korean chars weighted 1.7×, min 900 dxa, budget 9000 dxa)
fixed table layout (widths respected in Hancom)
- Row-based alternating shading — header navy, data rows blue/white alternating
- Uniform column styling (no first/last column special case)
- Cell vertical center alignment
- Minimal cell margins (top/bottom 20 dxa, left/right 80 dxa)
- Zero paragraph spacing, line spacing 1.0, empty paragraphs stripped
- Font size 10pt throughout (run-level +
pPr/rPr default)
- (Optional) Prepends a full-page cover image with page break
Inputs
Required:
- Input
.md file path
- Image folder path (for Pandoc to resolve
![[filename]])
- Output
.docx path
Optional:
- Cover image (
--cover path/to/cover.jpg)
Default palette (Korean gov proposal)
| Element | Hex |
|---|
| Header background | #1F3864 (dark navy) |
| Header text | #FFFFFF (white, bold) |
| Odd data rows | #D9E2F3 (light blue) |
| Even data rows | #FFFFFF (white) |
| Body text | #000000 (black) |
Customization: edit NAVY, LIGHT, WHITE constants at top of scripts/style_docx_tables.py.
Invocation
Full pipeline (most common)
bash ~/.claude/skills/docx-table-styler/scripts/md_to_docx.sh \
"proposal.md" \
"./도식" \
"proposal.docx"
With cover page
bash ~/.claude/skills/docx-table-styler/scripts/md_to_docx.sh \
"proposal.md" \
"./도식" \
"proposal.docx" \
--cover "cover.jpg"
Style an existing DOCX (skip MD conversion)
python3 ~/.claude/skills/docx-table-styler/scripts/style_docx_tables.py \
input.docx output.docx
Add cover page to existing DOCX
python3 ~/.claude/skills/docx-table-styler/scripts/add_cover_page.py \
input.docx cover.jpg output.docx
Success criteria
Constraints & pitfalls
- Obsidian wikilinks: Pandoc does NOT understand
![[file]] — the sed preprocessing step is mandatory. The wrapper script handles this; if bypassing to call pandoc directly, run the sed step first.
- python-docx API quirks:
CT_PPr.get_or_add_rPr() does NOT exist — create w:rPr manually via OxmlElement.
table.style = "Table Grid" may raise KeyError if the style is not present in the source DOCX — wrap in try/except (already handled in script).
row.cells returns merged cells multiple times; the script guards with min(len(cells), num_cols).
- Nested tables: the script recursively descends through
cell.tables.
- Hancom HWP compatibility: requires BOTH
tblGrid/gridCol widths AND tcW per cell AND tblLayout w:type="fixed". The script sets all three.
- Text color on empty paragraphs: must set BOTH run-level color AND paragraph-level
pPr/rPr/w:color so empty paragraphs under navy header render white, not black.
- Scale: 104-table document processes in ~5s on M-series Mac; larger docs scale linearly.
Known limitations / open branching decisions
- Row banding only (no column banding alternative)
- Single header row assumed (multi-row header detection not implemented)
- LTR languages only (no RTL handling)
- Wide tables (10+ columns) may look cramped at 9000 dxa budget — consider landscape page orientation
- HWP conversion is manual (open in Hancom → save as
.hwp); no CLI automation included
After this skill
User opens the resulting .docx in Hancom 한글 → 파일 → 다른 이름으로 저장 → .hwp or .hwpx.
Hancom post-processing typically needed:
- Font substitution (제안서 표준: 함초롬바탕 / 함초롬돋움)
- Page margin adjustment (정부 표준: 상하좌우 25mm)
- TOC regeneration (입력 → 차례 → 차례 만들기)
Verification commands
unzip -p output.docx word/document.xml | tr '<' '\n' | grep -c '^w:tbl '
unzip -l output.docx | grep -c 'word/media/'
unzip -p output.docx word/document.xml | grep -o 'w:fill="[0-9A-Fa-f]*"' | head -5
File layout
~/.claude/skills/docx-table-styler/
├── SKILL.md # This file
└── scripts/
├── md_to_docx.sh # Full pipeline wrapper
├── style_docx_tables.py # Table styling engine
└── add_cover_page.py # Optional cover page inserter