Skip to content

hanriverflow/ib-report-formatter

v0.2.0MIT

Create Korean business documents and term sheets from source material, then strictly render Markdown to Word.

IB Report Formatter 2.0

Markdown → editable Word for investment-banking reports and Korean business documents.

한국어 설명 · Current integration record · Release checklist

Choose how you work

One Markdown-to-Word engine, three delivery formats. Choose by workflow, not by branch or document type.

Your goalDistributionWhat you need
Convert prepared Markdown to editable WordDocument Converter · Windows portableWindows x64; Python bundled; no AI account
Ask AI to draft and revise documents in your own workspaceAI Document Assistant · Claude Code / Codex pluginSupported host and account, uv; Python 3.12 prepared as needed

Start here: setup and distribution selection · Plugin installation · Published downloads

Advanced: Codex Project Kit (source distribution)

Open the extracted source folder itself as a Codex project to learn from examples, customize the workflow or modify code. Requires Codex, uv and Python 3.12+. This is not a more capable document engine than the plugin. Project setup · Detailed local HTML guide

Versions: engine 2.0.0 (Beta); plugin 0.2.0. These are separate version lines, not successive editions. ZIP and .plugin contain the same plugin; Claude web/Cowork execution is not verified. Source availability does not mean a downloadable release has been published. See verification scope.

Then choose a document profile: general business (letters, reports, minutes), IB reports/memos, or term sheets with institution-specific YAML settings. All distributions share the same engine; do not select a feature branch for a document type. Profiles · Build and release guidance for maintainers

Status and documentation map

Release state on 2026-11-15: the default branch is main and package metadata declares 2.0.0 (Beta). Two prereleases are published: v2.0.0-beta.1 (2026-10-08) and v2.0.0-beta.2 (2026-11-15; engine 2.0.0, plugin 0.2.0); see the changelog. A release tag names a delivery set; the engine metadata stays 2.0.0 (Beta) across these prereleases. These labels are not a certified v2.0 release.

  • Current usage and implementation: this README, Korean usage, runnable profiles, CLI source, profile definitions, and tests. The built-in direction is Markdown to DOCX; Word-to-Markdown remains retired.
  • Latest integration and reported verification: 2026-09-26 consolidation, including promoted functionality and deliberately deferred old-PR features. It reports 311 tests passed at product-code commit cadc0ae515d2f5757d5006e64bec1acaff56ccba, package/install checks, and nine synthetic documents / 16 pages of Word evidence. These are that record's results, not tests rerun during this documentation review or human/business approval.
  • 2026-11 hardening (released in 2.0.0-beta.2 on 2026-11-15): asset path restriction, input limits, rejection codes, the Word schema CI gate, and snapshot and property tests are described in Allowed asset folders, input limits and rejections and the 2.0.0-beta.2 section of the changelog. Their recorded scope, environment and unverified items are in the 2026-11 verification record.
  • Design and earlier evidence: September implementation plan, September 14 verification, letter improvement plan, and September 15 verification. Plans explain intended work; dated verification records describe only their recorded scope and environment.
  • Preserved historical plans: stability plan, upgrade plan, next steps, and roadmap, kept under docs/archive/ in the repository only. Their bidirectional features, old test counts, and checkmarks are not the current feature list or a release guarantee.
  • Preserved upload checklist: git_checklist.md is an older repository-upload guide, not evidence that release gates have passed. Use the release checklist below for a future release. Do not reinitialize this repository or blindly stage all local files.
  • Change history: CHANGELOG.md. A dated entry or completed plan alone does not prove a tag, published artifact, or successful validation of today's checkout.

Release checklist

This is a pending maintainer workflow, not a completed deployment. This documentation-only review did not run tests, build/install packages, render Word pages, publish packages, or create tags/releases.

Local validation commands

Run from a clean, isolated checkout of the exact proposed release commit, using both Python 3.12 and 3.13. Preserve command output, tool versions, exit codes, and artifact hashes. These commands are instructions, not fresh pass results:

uv sync --locked --extra dev
uv run pytest tests/
uv run ruff check .
uv run ruff format --check .
uv run mypy .
uv run md-to-word --help
uv run md-to-word --list-profiles
uv run md-to-word samples/profiles/office-letter.md release-letter.docx --strict
uv run docx-audit release-letter.docx
uv build

Keep generated output local and outside commits. For repeated runs, choose a new output path. Inspect the audit JSON; successful DOCX generation is not proof of acceptable page layout. See Word page QA on Windows for native rendering with new/empty evidence directories and separate visual review.

  • Record the exact release commit and reconcile both READMEs, package version and changelog with its implemented scope, not historical plans.
  • Run the checks above; investigate every failure. Recheck the declared Python/OS support on actual target runtimes; Python 3.12 syntax checks alone are not runtime validation.
  • Inspect wheel/sdist contents for missing engine modules and accidental credentials, private reports, generated DOCX files, or retired inverse-conversion modules. Install the built wheel in a separate clean environment and smoke-test its installed CLI outside the source checkout.
  • Regenerate representative synthetic samples; inspect structural audit results and every rendered Word page. Record Word/font environment, manifests, hashes, and separate visual-review/business-approval status.
  • Resolve the rights and notice gate below, including third-party dependencies, fonts, images, diagrams and sample content.
  • Only after those gates pass, have the maintainer choose a version consistent with package metadata and changelog, create a tag on the validated commit, and publish release notes with the exact validation evidence, limitations and artifact hashes. Do not infer or create v2.0/v2.0.0 merely from the README heading. Never move an existing release tag to hide a failed validation; document a corrected release instead.

License and rights gate

The project is licensed under the MIT License, matching the existing license = {text = "MIT"} declaration and classifier in pyproject.toml. On 2026-09-29 the rights holder confirmed the copyright notice Copyright (c) 2026 Hank; the LICENSE file carries it and is included in the sdist and wheel metadata.

[open] Third-party notices: dependency, font, image, diagram and sample-content licenses are separate from the project license. Confirm them before a public release; the MIT notice does not cover third-party material.

Product direction

This is a Markdown-to-Word-only engine. In-house Word→Markdown development has been retired deliberately: established external projects already address that problem. Version 2 removes the inverse parser/CLI, Markdown output converter, OMML reverse converter and roundtrip audit. There is no plan to rebuild them.

Quick start

Advanced: write with the Codex source project

Open this source folder as a local project in the Codex app and ask $ib-document to draft a document from your supplied facts. Codex writes/revises Markdown and runs this repository's strict renderer; no separate LLM client, project API key or EXE is needed. GitHub users can clone the project; other users can extract the source ZIP. See the Korean getting-started guide, repository skill and fictional authoring exercise. If the skill is not discovered, ask Codex to read its file path explicitly. Initial Python/uv setup and Codex model use can require internet access. Structural checks do not certify source accuracy or page layout.

Requires Python 3.12+. CI checks Python 3.12 and 3.13 on Ubuntu and Windows. Install with uv:

uv sync
uv run md-to-word samples/profiles/office-letter.md letter.docx --strict
uv run md-to-word samples/profiles/ib-memo.md memo.docx --strict
uv run md-to-word input.md output.docx --profile plain
uv run md-to-word --list-profiles
uv run docx-audit letter.docx

The existing uv run md_to_word.py ... and uv run ib-report ... commands still work. Word is not required to generate DOCX; it is useful for reviewing pagination and updating fields. Files locked by Word are saved to a timestamp-suffixed path, reported in the log.

Profiles

ProfileDefault compositionPage
ib-reportLegacy IB cover, TOC, disclaimer, confidentiality labelLetter
ib-memoCompact IB title/author/date, confidentiality label; no cover/TOC/disclaimerA4
plainBody only; no IB metadata inferenceA4
office-letterCompany, document number, recipients, title, attachments, senderA4
business-reportTitle, date, department, author, bodyA4
meeting-minutesTitle, time, place, attendees, author, bodyA4
term-sheetDeal opening, house boilerplate, merged term tables, confirmation boxA4

Profile defaults do not supply factual document content. The four general profiles do not infer financial tables or turn short numbered items into headings. They use neutral styling and editable Word multilevel numbering (decimal → Korean 가나다 → parenthesized decimal). Nest lists using four spaces per level. Legacy IB list behaviour is retained.

Frontmatter

Use the profile examples as starting points:

---
profile: office-letter
title: 자료 제출 요청
document_no: 기획-2026-015
date: "2026-09-14"
sender:
  organization: 주식회사 예시
  department: 경영기획팀
  signatory: 주식회사 예시 대표이사
  contact: planning@example.com
recipients: [협력회사 담당부서장]
cc: [재무담당자]
attachments: [제출 양식 1부]
---

Letters require recipients and sender.organization; no seal/signature image is manufactured. Reports use analyst, date, sender.department; minutes also accept meeting_time, location, attendees. Quote dates, codes and numeric-looking identifiers to preserve their text. A matching first H1 is not duplicated when the profile already supplies a title.

Version and DRAFT marking

version: "v1.2"   # quote it: unquoted 1.10 is read by YAML as 1.1
status: draft     # draft or final
  • version is written as the custom document property Version and shown in the page header after the company (예시금융 | v1.2, or v1.2 alone without a company). The header text is a DOCPROPERTY Version field holding the current value, so it reads correctly as soon as the file opens. Office letters write the property but show no version; the term-sheet footer keeps showing subtitle version, with the version part as the same field.
  • To change the version in Word, edit File > Info > Properties > Advanced Properties > Custom > Version, then update the field: double-click the header and press Ctrl+A, F9 (this updates that section's header only), or open Ctrl+P / print preview, which updates every section. Ctrl+A, F9 in the body does not update headers. Printing and saving as PDF use the new value.
  • status: draft puts a DRAFT watermark on every page, including the cover and landscape-table sections. It uses Word's own watermark shape, so Design > Watermark > Remove Watermark clears it from every page at once. status: final or no status adds nothing; any other value is rejected.
  • File > Info shows the document title, an empty author and comment, and the conversion time as the created and modified dates.

Letters with an appendix

The letter profile uses a centred company name, aligned recipient/reference/subject fields, attachment lines in the administrative-handbook form, a closing marker, signatory and issue/contact details. Wrapped metadata aligns below the value. The company name is not repeated in the page header. sender.signatory accepts a YAML multiline string; no signer name is invented.

To place the closing before an appendix, specify its exact H1 text:

letter:
  appendix_heading: 운영자료 확인 내역
  appendix_label: 붙임 1

That H1 must appear exactly once after the letter body and differ from the document title. Missing/duplicate/empty-body boundaries and unknown letter keys are rejected before saving. appendix_label is optional and requires appendix_heading. Without these settings the entire Markdown remains the letter body. Attachments are a declared list, not proof that external files exist or have been embedded. See the complete synthetic example.

Attachments, tables at the end and item symbols

These follow the Korean administrative-document rule (enforcement rule of the 「행정업무의 운영 및 혁신에 관한 규정」, Art. 2(1) and 4(4)–(5)) and the 2025 administrative handbook. The rule binds government bodies only; for a company's letters it is the form recipients expect, not a legal requirement, and the engine does not certify legal adequacy. Details: verification record.

  • Attachments. One attachment is one unnumbered line, 붙임 발행조건 요약표 1부. 끝.. Several start on the 붙임 1. line and the next numbers align under 1.; the numbers stay native Word numbering. 끝. follows the last attachment.

  • Body ending with a table. A table filled to its last row gets 끝. below it, one character in. If the final table is filled only partway (blank rows left for the record), declare it:

    letter:
      table_end: partial
    

    The first cell of the first blank row after the last written row then reads 이하 빈칸, and 끝. is omitted (it still follows attachments if there are any). The engine never infers this from blank rows, because a reply form keeps blank rows for the recipient. The setting is rejected before saving when its value is not partial, when the letter body does not end with a table, or when that table has no blank row after its last written row.

  • Item symbols. Nested numbered items in an office letter use 1. 가. 1) 가) (1) (가) ① (levels one to seven). Word has no automatic format for the eighth symbol ㉮: strict mode rejects an eighth level, and non-strict mode uses 가, 나, 다 with a warning. Word's 가나다 numbering returns to 가 after 하; the handbook continues with 거. Other profiles keep 1. 가. (1).

See the synthetic partial-table example.

Configuration precedence is explicit CLI/API option > YAML > profile default. YAML layout supports boolean cover, toc, disclaimer, confidential, strict, plus separator_mode: auto|rule|page-break. Unknown layout/table/theme keys fail validation. CLI overrides: --profile, --theme, --strict, --no-cover, --no-toc, --no-disclaimer, --no-confidential, --separator-mode. Enable cover/TOC through YAML or API when needed.

Themes: default, mono, or a small YAML file using body_font, heading_font, korean_font, body_size, primary_color, margin_mm. See company-theme.yaml. YAML theme paths are relative to the input Markdown; CLI paths are relative to the working directory. This is not an arbitrary DOCX template importer.

Term sheet

Use profile: term-sheet for Korean structured-finance terms. See the fictional ABCP sample and fictional house file.

---
profile: term-sheet
title: "가나다머티리얼즈㈜ ABCP 300억원"
date: "2026-10-16"
version: v1
house: term-sheet-house.yaml
tables:
  - {}
  - {columns: [text, date, date, number, number, number], unit: 억원}
---

title is required; subtitle defaults to Term Sheet. Optional date is displayed as written and version labels the footer. prepared_by and disclaimer must be nonblank in frontmatter or the house file. House YAML accepts only prepared_by, disclaimer, confidential_label, confirmation (intro, a list of items, signature) and style. Frontmatter keys override house values, including an explicitly empty value; style settings override key by key. House prose supports inline emphasis such as ( *주요내용* ).

style sets the house layout; every key is optional and the defaults are the standard layout:

style:
  cover: page            # inline (default) | page: title block, logo and disclaimer on a cover page
  logo: assets/logo.png  # image path (relative to the house file, or to the Markdown in frontmatter) or data: URI; "" removes a house logo
  logo_width_mm: 40
  disclaimer: box        # rules (default) | box
  header_rule: true      # accent rule under the header
  footer_rule: true      # accent rule over the footer
  label_color: "#C00000" # confidentiality label colour; "" keeps the default grey
  page_number: "- {page} -"   # default "{page} / {pages}"
  page_number_align: center  # right (default) | center
  table_header: dark     # light (default) | dark: accent fill, white text
  table_sides: open      # closed (default) | open: no outer left/right borders

Omit a key to keep its default; a null value is rejected. A logo that cannot be loaded is a render diagnostic that strict mode rejects. Keep real institution logos outside the repository, like real house files.

Keep real deal documents and real institution house files outside the repository. Frontmatter house paths resolve relative to the source Markdown; --house /absolute/path/to/house.yaml overrides that file, with relative CLI paths resolved from the working directory. String/stream input without a source path needs an absolute house path. The checked-in house file contains fictional wording only.

Write numbered sections explicitly with ## and subsections with ###. Table specifications follow body-table order; retain {} for tables with no overrides. The snippet above illustrates a two-table document; use the complete sample's ordered specifications when copying its tables.

  • A cell containing only ^^ merges upward; << merges left. Merges must form rectangles and cannot cross the header/body boundary. Empty cells stay empty. Use \^^ and \<< for literal markers. Invalid groups retain their source markers with warnings; strict mode rejects them.
  • Spans default on for term-sheet; spans: false disables them. Other profiles enable them only with spans: true.
  • label_columns overrides the leading label count (integer from 0 to one less than the column count). Otherwise the first header cell's resolved span determines it, capped at column count minus one. Thus | 구 분 | << | 내 용 | gives two labels; | 구 분 | 내 용 | gives one.
  • Key-value tables have one or two label columns and exactly one content column. The first label is shaded/bold, with a fixed 33.5 mm width; the second is white, regular/muted, 30 mm wide. Other grid tables size each column so its lines fit on one line, then share the spare width equally; when the content cannot fit side by side they use the content-based estimate. Their labels are regular-weight and shaded. Use label_columns: 0 for no label shading.
  • A cell that starts in the second label column and spans into the content columns is laid out as content (left-aligned, unshaded). A label in the first column stays a label however far it spans, as in a totals row.
  • header_rows: 2 (default 1) draws the first two rows as the header: shaded, merged where spans say so, and repeated on every page. The second header row is the first Markdown row after the delimiter. Merges may join header rows but not cross into the body. base_case rows then count from the first body row.
  • Use columns roles for dates, codes and numeric values, and unit for units above the table. note is optional text placed below the table, right-aligned and muted (8 pt); every profile supports it. Financial meanings are not inferred and schedules are not calculated; a declared schedule is only checked (see Numeric checks).

Use <br> inside cells; in term-sheet body paragraphs it also starts a separate Word paragraph. Line markers receive hanging indents: •, -, · start at 0/3/6 mm with a 3 mm hang; ①–⑳ start at 0 with a 4.5 mm hang; ※ starts at 0 with a 4 mm hang and 8 pt text. Wrapped text aligns after the marker. A body Markdown - list retains normal list handling.

Place an empty, closed fence where the house/frontmatter confirmation should appear:

```confirmation
```

The box has an introduction/checklist row and a shaded, centred signature row kept on one page. Missing text, a nonempty fence or an unclosed fence preserves the source in a diagnostic code panel; strict rendering rejects it. Other profiles treat the fence as code.

Every page uses confidential_label (default Strictly Confidential) in the header. An empty label, layout.confidential: false, or --no-confidential suppresses it. The footer shows subtitle version when version is present (the version is a DOCPROPERTY Version field; see Version and DRAFT marking), plus PAGE / NUMPAGES. The opening disclaimer remains required even with --no-disclaimer. The existing termsheet preset only toggles cover/TOC/end-disclaimer sections; it does not select this profile, load house text or apply term-sheet table formatting.

Term-sheet documents wrap Korean at word boundaries (w:wordWrap=1) and turn off Word's automatic spacing between Korean and Latin text or digits (w:autoSpaceDE/DN=0), so amounts print as 300억원 and SPC에.

Term variables and consistency checks

Define values that repeat across the document (amounts, rates, dates) once under frontmatter terms: and reference them as {{key}}. Every profile supports this.

terms:
  amount: "300억원"
  cap_spread: "[1.10]%p"
  • Keys start with a lowercase letter and use lowercase letters, digits and underscores (at most 40 characters). Values must be single-line strings; quote anything YAML would read as a number (1.10 would otherwise become 1.1).
  • References are substituted in the title, subtitle and date, headings, paragraphs, lists, table cells and blockquotes. Table captions, units, sources and as-of dates receive plain, untagged text. Inline code, code blocks, math and link destinations are never substituted. \{{ stays literal.
  • Values are inserted exactly as written: they are not parsed as Markdown and table number formatting does not apply. Surrounding bold/italic is inherited.
  • An undefined key is left as {{key}} with a warning, and strict mode rejects it. Without terms:, {{…}} is ordinary text; terms: {} turns the feature on and checks every reference.
  • Each substituted value is wrapped in a Word content control tagged ibrep:term:<key>, and the generated value is recorded in the custom document property ibrep.term.<key>. For a clean copy without controls, use --no-term-tags or layout: {term_tags: false}.
  • After editing in Word, docx-audit adds a terms object to its JSON: mismatched (one key with different values), changed (values edited since generation, to carry back into the YAML), missing (keys whose controls were all removed) and indicative (values still in brackets). These are warnings; they do not affect issues or the exit code. The check covers consistency between tagged values only, not financial correctness.

Numeric checks

Declare arithmetic that the terms must satisfy under checks:; every profile supports it.

checks:
  - "all_in = issue_rate + credit_fee + running_cost"
  - "facility = amount * 1.05"
  - {check: "upfront = advisory + legal + audit", tolerance: "30만원"}
  • A relation has one =. Each side combines term keys and plain numbers with + - * / and parentheses.
  • Values are read as displayed:
    • Korean money: 10억원, 3,330만원, 5억 3,000만원, 1,076,175,000원.
    • Percentages and points: 4.78%, 1.10%p, 29bp.
    • 36개월, 4.54년 and plain numbers.
    • Brackets and the words 약, 총, 내외, 수준, 정도 are ignored.
  • Money and percentages are never mixed or rescaled.
  • By default the sides must agree within half of the display step of the left value, so a stated 12.66억원 agrees with any amount that rounds to it. Give an explicit tolerance to allow more.
  • A failing or unreadable check is a warning, and strict mode rejects it. The checks are stored in the DOCX (property ibrep.checks, with the generated values). docx-audit re-evaluates them with the current tagged values and reports failures under terms.failed_checks.

A repayment schedule table can declare its columns so its arithmetic is checked:

tables:
  - unit: 억원
    schedule: {repayment: 5, balance: 6, months: 4, principal: "{{amount}}", total: true, average_life: "{{wal}}"}
  • repayment and balance are one-based columns; months (elapsed months) is optional.
  • principal is a number in table units, or a term or value in money that is converted with the table unit. Without it, the first row's balance plus its repayment opens the schedule.
  • total: true marks the last body row as a totals row.
  • The checks:
    • each balance equals the previous balance minus that row's repayment;
    • the last balance is zero;
    • the repayments add up to the principal;
    • the totals row shows their sum;
    • average_life (years, or 개월) matches the repayment-weighted months divided by 12.
  • Blanks, dash placeholders and text such as 대출실행 count as no repayment. A dash balance means nothing is left.
  • Disagreements are warnings (strict rejects them). Nothing is recalculated or rewritten.

Converted input (HWP/Word)

Markdown from an external HWP or Word converter needs cleanup before it is term-sheet input. The cleanup is an explicit MD→MD step; review its report and the output before rendering:

uv run md-format converted.md term-sheet.md --converted-term-sheet
  • A one-line paragraph 1. Title (a one- or two-digit number, 1\. too, and at most 40 characters after it) becomes ## 1. Title when it is bold or directly followed by a pipe or HTML table. Other numbered text is unchanged, and the parser never promotes it by itself; a one-line numbered paragraph that stays text is reported so you can check whether it is a chapter.
  • A table with a header row and no body rows, such as | 별첨 | | 상환스케줄 |, becomes the heading ## 별첨 | 상환스케줄. A table stays a table (and is reported) when the heading text would hold characters the inline parser reads as syntax (*, _, $, ^, ~, `, brackets, <, >, backslashes or entities), or when an HTML table has anything outside its cells (a caption or a comment, for example) or cell markup other than one <p> and bold, italic, underline or span tags (a <br>, <sup> or link, for example).
  • Blocks before the first chapter heading (or a one-row table kept as a table) are the cover. The first confidentiality line becomes confidential_label and identical repeats are removed. The leading bold lines (or a level-1 heading) become title and then subtitle, a date line becomes date, and paragraphs of 80 characters or more become disclaimer (a hard break, \ or <br>, becomes a line break; an escaped \<br> stays text). Cover images are removed and reported, so you can use the logo as the house style.logo.
  • Only top-level blocks change. Indented code, list items and their continuations, block quotes, fenced code and HTML tables (nested ones included, apart from the one-row band tables above) stay as written. A # heading ends the paragraph before it, and any heading of level 2 or more, even indented, ends the cover.
  • Lines the cleanup cannot classify stay where they are and are reported. prepared_by is never inferred; put it in the house file or frontmatter. Existing frontmatter lines and keys (compared without case, as the parser does) are kept, new keys go before the closing ---, and a cover line whose key is already set stays in the body. A YAML ... closer becomes ---, and flow-style frontmatter ({...}), which the parser does not read, is rewritten as block YAML; both are reported.
  • Every moved, rewritten, removed or kept line is printed with its input line number (a range for multi-line changes). This mode replaces the Deep Research formatting for that run and cannot be combined with --check or a non-default DeepResearch option.

Charts (opt-in)

md-to-word report.md report.docx --charts --strict
md-to-word samples/qa/charts-dcm.md charts-dcm.docx --strict
md-to-word report.md code-panels.docx --no-charts

Charts are off by default for all seven profiles. Enable with --charts, RenderOptions(charts=True), or top-level frontmatter charts: true. An explicit CLI/API value wins over frontmatter; --no-charts / charts=False forces code panels. The parser retains the original fence in a chart model element so the same parsed model supports either setting.

```chart
chart_type: stacked_bar
title: 2028 maturities are the largest at KRW 400bn
subtitle: "Maturities by year, KRW 100m"
labels: ["2026", "2027", "2028"]
series:
  - name: Public bonds
    values: [1200, 2500, 3100]
  - name: Bank loans
    values: [300, 500, 900]
totals: true
number_format: ',.0f'
note: Balances at the end of September 2026
source: Company data (fictional)
```

Changed appearance (2026-11-14). Charts are drawn in an IB/consulting style by default (chart_style: standard): the theme's primary colour as the one accent with greys, values written on the bars instead of a value axis (a line chart keeps a value axis), a zero baseline without a frame, the legend above the plot (one row, more when the names do not fit in one), line names at the line ends, hatched decreases, and tones chosen so that series stay apart when printed in black and white. The title and subtitle are Word paragraphs above the picture and the note and source Word paragraphs below it, kept on one page with the picture. Documents written before this change look different. To keep the earlier look, set frontmatter chart_style: classic (or RenderOptions(chart_style="classic")): it draws bar, line and waterfall charts that use only the earlier keys exactly as before; any chart using a newer type or key is drawn in the standard style.

TypeDrawsSeries
barGrouped vertical barsone or more
lineLines, names at the line endsone or more
waterfallRunning total from zero plus a total barexactly one
stacked_barStacked bars (maturity profile, funding mix)one to four; values not negative
bar_lineBars on the left axis and lines (axis: right) on the right axis, values written, axes hiddenone or two each
rangeHorizontal bars from low to high (valuation football field, rate band)none: low and high lists
hbarHorizontal bars in the written order (rankings)exactly one
KeyTypesMeaning
title, labels, series, source, number_format, total_labelall as beforetype aliases chart_type
subtitleallLine under the title, as written. Without it, y_label or unit is shown there as written; the engine adds no words
noteallLine above the source
highlightbar (one series), hbarLabels drawn in the accent colour, the rest grey
accent_seriesbar, lineSeries in the accent colour; default the last series ("later is darker")
referenceline, rangeUp to two {name, value} reference lines
totalsstacked_bartrue writes each stack's total above it: the exact sum of the numbers as written, rounded once. Off by default
start_totalwaterfalltrue draws the first value as a balance, like the total bar
low, highrangeBounds per label; low must not exceed high
show_overlaprangetrue shades the span where every range overlaps
right_number_formatbar_lineFormat of the right-axis lines, as number_format
axis (in a series)bar_lineright for the line series

A key on a type it does not apply to, a missing or misplaced key, and any invalid value are chart specification errors. number_format adds number (the default), percent, bps, multiple, or fixed-point formats such as ',.2f' / '.1f'. Formats never rescale values: 12.5 with percent displays 12.5%. The only numbers the engine works out are the waterfall's running total and, with totals: true, stack totals; each is the exact sum of the numbers as written ([0.3, -0.1, -0.2] totals 0), rounded once. Waterfalls start at zero, cumulatively add every supplied value, then append a total: [100, -30, 20] ends at 90. Do not supply a precomputed total as another delta. More than four compared series still draw, with a rendering warning, because they cannot be told apart in black and white.

Rounding (owner decision 2026-11-14). The decimal places depend on the format and are the same in both styles: without a format and with number, percent, bps and multiple, a whole number is written without decimals and any other number with one decimal; a fixed-point format writes its own (',.2f' two, ',.0f' none). The two styles round differently:

StyleA 5 is rounded4.125 as ',.2f'2.5 as ',.0f'0.25 (no format)2.675 as '.2f'
standardaway from zero, as a spreadsheet's ROUND does, on the decimal as written4.1330.32.68
classicas before: to the even digit, on the binary number the computer holds4.1220.22.67

In a standard chart this holds for every number in the picture (values, totals, line ends, reference values and the value-axis numbers of a line chart), and a negative amount that rounds to zero is written without parentheses (-0.04 is 0.0). Numbers are read with about 15 to 17 significant digits; a longer one is written as the nearest number the computer can hold (9007199254740993 as 9,007,199,254,740,992). A line chart's value axis writes a number only where the text, read as a decimal, is exactly the tick's position, with no tolerance (a tick at 1,000,000,000.5 is not written 1,000,000,001), and only when no other tick has the same text; with fewer than two such ticks it writes none, and the values at the points remain. A $ in a name is drawn as written and never starts mathematical notation.

Every value is written on its own mark or reported. Each number a chart writes (bar, segment and point values, stack and waterfall totals, line ends, range bounds, reference values) is drawn only where all of the following hold (the final rule, 2026-11-14): (a) whole inside the picture; (b) clear of every other text; (c) clear of every mark it is not written in: other bars and segments, every line with its width and every point marker (its own series' included), reference lines, the zero line and a waterfall's connectors; only a value written inside its own bar or segment lies on a mark; (d) on its own mark (inside its bar or segment, centred over or under its bar or point within 16 pt, or level with its row within 16 pt), and its own mark is the nearest to the text's centre, bars and plotted points taken together: no other bar (for a bar's value) and no other point (for a point's value) is nearer than its own by more than 3 pt, and its own mark is nearer by at least 3 pt than every mark on the text's own centre line, where only the distance tells them apart: every mark of the other kind (a point of any series for a bar's value, a bar for a point's value) and, for a point's value, every other series' point of the same category. Whose a mark is, is known by its series and category, never by where it lies: another series' point of the same category is a rival also when it lies on the value's own point. The one exception: two series' points of one category on the same spot (within half a pixel) that are written with the same text, as where two index lines both start at 100. That number is true of both points, so it is written once and the value that is not written is not listed as missing; with different texts (100.00 and 100.01) the value is left out and named. Exception to (d) for horizontal charts (hbar, range), approved in the fourth review: there a value runs sideways from the end of its bar, so a longer bar in the next row is always nearer to the text's centre; instead of the nearest-mark test, the text's centre must lie within its own row's height, at most 16 pt beside the bar, and (f) applies as everywhere; (e) a stacked segment's value goes inside the segment when its text fits there, otherwise beside the bar (right, then left), inside the category's own column, above the baseline, with the text's centre within its own segment's height, not level with another value beside the same bar, and not as high as a whole other segment of that bar (two thin segments level with one number cannot be told apart); a segment of 0 has no height and no value; (f) a value written outside its mark (over, under or beside it) has nothing between: the band from the text to its own mark (the rectangle joining the two, as wide or as high as the text) holds no other bar or segment, no line, no point marker and no reference line. Only the two pieces of the value's own series' line that meet at its own point, and its own point's marker, are not counted; another series' line is, also when it leaves from the very same spot. Line-end names and reference-line texts follow (a) to (c), and a line-end name is nearest to the end of its own line (no other line ends nearer to it by more than 3 pt); when one is left out, a second warning says which line or reference line is drawn without a name. A line-end name wider than 40 % of the picture is broken into lines. Line ends are spread 11.5 pt apart where the picture has room (closer ones are kept only if they do not overlap), and a line chart is at least (series × 11.5 pt + 0.75 in) high, up to 9 in. After the values are placed the drawn picture is checked again and a value that fails is removed. No place is tried beyond these and no leader line is drawn, so crowded charts lose values (the verification record gives the share by chart type). A value with no such place is left out and named, with its category and series, in one warning per chart: it is logged (so md-to-word prints it) and listed in IBDocumentRenderer.warnings, the registry's render_warnings and scripts/agent_render.py's render_warnings; it never rejects a document. Long legend and category names are broken into lines; an axis name or legend entry that still leaves the picture or overlaps another is named in a warning.

A standard chart's picture is at most the body width (6 in at most) and at most the section's body height (page height less the top and bottom margins) less 1.1 in for its title, subtitle, note and source; a taller picture is narrowed in proportion, so its text gets smaller. Where the body is too short for that, the picture keeps 0.5 in but is never taller than the body itself. The 1.1 in is a fixed allowance: a title, subtitle, note or source that runs over several lines can still push the picture to the next page. Classic charts keep their earlier size.

The words before the note and source and the default total label follow the profile family: Note, Source, Total in the IB profiles, 주, 자료, 합계 in the general profiles and the mono theme. A theme file can set CHART_NOTE_LABEL, CHART_SOURCE_LABEL and CHART_TOTAL_LABEL. Chart texts are plain text, not Markdown; a @tbl-…/@fig-… written in a chart title, subtitle, note or source stays text and is reported (strict mode rejects).

Invalid YAML/specifications and rendering failures name the chart in diagnostics. Strict mode rejects before creating/replacing the output; non-strict mode displays the original code panel and logs a warning. Disabled charts remain ordinary code panels even if their YAML is invalid: with charts off (frontmatter, --no-charts or the API option) a chart block is a code block in every respect, whatever it holds. Its id numbers nothing and is no reference target, so a document converts exactly as it did before chart IDs existed, and a @fig-… that names such a chart is reported like any reference to an unknown ID. A caller who overrides the chart setting passes the same setting to the parser (MarkdownParser(charts=…), parse_markdown_file(charts=…)), as with the profile; md-to-word and the registry do. Where the two settings differ, a document with chart IDs follows four rules (fifth review, 2026-11-15). (G1) The parser keeps a record of the other reading on the model object alone: its own setting, the model read for the other setting and a copy of the model as parsed. Elements and metadata carry nothing, and two readings that are equal leave no record. copy.deepcopy and pickle keep the record. A model made with dataclasses.replace has none, like a model built by hand, and is drawn as given; to draw it with another chart setting, give the parser that setting. (G2) A render with the parser's setting, or of a model without a record, draws the model it is given. (G3) A render with the other setting of a model that is equal in value to its copy as parsed draws the other reading, whole: with charts on its charts are drawn and numbered and the references to them resolve, with charts off the document is the one without chart IDs. (G4) A render with the other setting of a model that was changed after parsing draws the model it is given and adds one diagnostic for the document (The document was changed after it was parsed with charts off; this render has charts on, so references to chart IDs are drawn as parsed. Parse it again with charts=True); strict mode rejects before saving. The diagnostic does not depend on what was changed, and the parser's own diagnostics are kept. A model that holds a NaN can compare unequal to its own copy (it always does after pickling) and then follows G4. Charts are PNG images up to 6 inches wide (the content width if narrower), with request-local colors and Korean font policy. Korean text needs the configured font installed (Windows default: Malgun Gothic). Samples: every chart type in a fictional DCM review and the three original types.

Section presets

md-to-word --list-presets
md-to-word report.md terms.docx --preset termsheet
md-to-word notes.md notes.docx --profile plain --preset lecture-note --no-cover
PresetCoverTOCDisclaimer
ib-reportInheritInheritInherit
termsheetOffOffOff
legal-memoOffOnOff
lecture-noteOnOnOff

Also available through RenderOptions(preset="termsheet") or top-level frontmatter preset: termsheet. Resolution per section is: explicit CLI/API field > CLI/API preset field > individual YAML layout field > YAML preset field > profile default. ib-report supplies no overrides. Unknown preset names fail without saving.

All presets work with all seven profiles; they change only sections. The general profiles retain neutral metadata, native numbering and general table semantics. termsheet is useful with ib-report/ib-memo, legal-memo with ib-memo/plain, and lecture-note with plain/business-report. Covers/TOCs are usually unnecessary for an office-letter or short meeting-minutes document. Presets supply no legal wording or document-type metadata.

Without a cover (--no-cover, API include_cover=False, YAML layout.cover: false, or termsheet/legal-memo), ib-report begins the document with a theme-aware title, optional subtitle, and the same date/author rows as ib-memo; any TOC follows on the same page, retaining its page break before the body. A matching body H1 and inferred subtitle appear only in that block and do not enter the TOC; cover-on output and other profiles keep their existing title behavior.

Extended themes

The six existing lowercase theme keys remain supported. YAML themes also accept these typed, uppercase presentation fields from IBStyle (PR #5 spelling):

CategoryKeys / units
ColorsNAVY, DARK_GRAY, LIGHT_GRAY, ACCENT_BLUE, WHITE, RED, GREEN, ORANGE, MEDIUM_GRAY, CODE_BG, CHART_NEGATIVE_COLOR, TABLE_HEADER_COLOR
OOXML colorsNAVY_HEX, LIGHT_GRAY_HEX, ACCENT_BLUE_HEX, GRAY_BORDER_HEX, YELLOW_HEX, TABLE_HEADER_BG
FontsHEADING_FONT, BODY_FONT, KOREAN_FONT, COVER_FONT, TOC_FONT
Point sizesH1_SIZE–H4_SIZE, BODY_SIZE, SMALL_SIZE, TABLE_HEADER_SIZE, TABLE_BODY_SIZE
Point spacingH1_SPACE_BEFORE/AFTER, H2_SPACE_BEFORE/AFTER, H3_SPACE_BEFORE/AFTER, BODY_SPACE_AFTER, BULLET_SPACE_AFTER
Inch lengthsTOP_MARGIN, BOTTOM_MARGIN, LEFT_MARGIN, RIGHT_MARGIN, BULLET_INDENT, DEEP_LIST_INDENT, MAX_LIST_INDENT
OtherBODY_LINE_SPACING (positive multiplier), FULL_LIST_INDENT_LEVELS (integer 0–9), BULLET_CHAR, TABLE_ZEBRA, BODY_JUSTIFY, HEADING_BORDER (booleans), TOC_TITLE, PAGE_LABEL, PAGE_OF_LABEL, CHART_NOTE_LABEL, CHART_SOURCE_LABEL, CHART_TOTAL_LABEL (text)
NAVY: "234567"
H1_SIZE: 18
BODY_FONT: Calibri
KOREAN_FONT: Malgun Gothic
BODY_SPACE_AFTER: 6
TOP_MARGIN: 0.8
CHART_NEGATIVE_COLOR: "995544"
TABLE_ZEBRA: false

Quote six-digit hex colors ("#234567" also works). Numeric colors, booleans used as sizes, nonfinite numbers, unknown fields and conflicting aliases are rejected before saving. Sizes allow 1–144 pt; spacing allows 0–144 pt; inch lengths allow 0–3; line spacing allows greater than 0 through 5. The existing body_size alias retains its 6–30 pt range and margin_mm retains 5–60 mm. Font names must be nonempty. Internal STYLE_* identifiers and the profile's NATIVE_NUMBERING policy are not theme fields.

RGB/hex color pairs are synchronized when only one is supplied; both may be set independently. NAVY also colors IB table headers unless TABLE_HEADER_BG is specified. RED supplies the waterfall negative color unless CHART_NEGATIVE_COLOR is specified. NAVY is the charts' one accent colour; the other series get greys (and, in stacks, tints of NAVY) chosen for their grayscale distance from it, so general/mono charts stay neutral. Headings, callouts, code panels and charts read the immutable style for the current request; default and mono retain their existing document output.

Explicit financial tables

tables:
  - type: financial
    columns: [text, money, percent, code]
    caption: 실적 요약
    unit: 금액 백만원
    as_of: "2026-06-30"
    source: "[회사 자료](https://example.com)"
    landscape: false
  - type: sensitivity
    base_case: {row: 2, column: 3}
  - type: financial
    subtotal_rows: [3, 5]   # body rows: the first row after the header rows is 1
    total_rows: [8]
    negative: paren         # paren (1,234), minus -1,234 or triangle △1,234

Specifications correspond to body tables in order; use {} to skip one. header_rows (default 1) sets how many leading rows form the repeating header in every profile. Supported types: generic, financial, sensitivity, risk. Supported column roles: text, code, date, number, money, percent, bps, multiple. If supplied, roles must cover every column.

Without roles, a column is numeric (right-aligned) when most of its first body values are numbers; empty cells and dash placeholders (-, –) are skipped. Number/money add thousands separators. Percent/bps/multiple append display suffixes to plain numbers; they do not rescale values (12.5 becomes 12.5%, not 1250%). Code/date/text roles preserve values such as 001234. Blank cells and escaped pipes A\|B retain their positions. Headers repeat across pages; rows are kept together when Word permits. landscape: true places that table in a separate landscape section, then restores portrait geometry.

Sensitivity highlighting is explicit only: row 1 is the first data row; columns are one-based and include the label column. The old guessed centre-cell highlight is removed. Risk highlighting recognises supported risk headers and levels such as high/medium/low or 높음/중간/낮음.

Totals and subtotals are explicit only, in every profile. subtotal_rows lists body rows that get a single rule above and bold text; total_rows lists body rows that also get a double rule below. Row 1 is the first row after the header rows, so with header_rows: 2 the third Markdown row is row 1. Rules use the profile's table accent colour (navy in the IB profiles, dark grey in the general profiles, the term-sheet navy); when a totals row is the last row its double rule takes the place of the table's bottom border. A row reading 합계 or Total gets nothing unless it is listed, and schedule.total only checks. A merged cell crossing a listed row stays one cell: Word draws no rule inside it. Lists that are not integers, are out of range, repeat a row, or name one row in both lists are rejected in strict and non-strict mode.

By default a financial table keeps each negative amount as written ((1,234) or -1,234) and shows it in red. A type: financial spec can set negative: paren, minus or triangle instead: that table's negative amounts become (1,234), -1,234 or △1,234, and the automatic red is off.

  • A cell is restyled only when its whole text is one negative amount in a numeric column, written -…, −…, (…) or △…. The unit may sit inside or after the parentheses ((3.5%), (3.5)%), and every written form of one amount gives the same text.
  • The digits and the unit stay; thousands separators are added and a unit goes inside parentheses ((3.5%), (1,200억원)). A bare number in a percent, bps or multiple column gets that column's unit, as it does without the option.
  • Everything else keeps its written form: ranges such as 1-2, several numbers or words in one cell, negative zero, text, code and date columns, ▲/▼ and tokens such as NM.
  • An amount whose integer part starts with a zero ((0001.20%), −0001200, -01,200; it may be a code) is not restyled. It keeps the existing number formatting, so it shows the same text as in a table without the option; in some forms (-0001200, (0001.20)%, -00.5) that formatting drops the leading zeros, as it always has. Full-width digits are read as that formatting reads them (-1234 gives (1,234) with paren).
  • Not restyled either, and shown as in a table without the option: a currency sign (-$1,200, ₩-1,200), a space between the sign or parentheses and the digits (- 1,200, ( 1,200 )), -.5, exponent notation, full-width parentheses, USD or %p suffixes, a footnote marker before the amount, and an amount written wholly in superscript. The units 백만원, 천원 and bp are supported.
  • An amount split across differently formatted text (-1200**.50**, -**1200**, -1200^.50^) also keeps its written form, and the conversion logs a warning. The warning does not make strict mode reject the document. Spaces and footnote markers before or after the amount (&nbsp;, a line break, [^1]), in any order and number, are not part of it: their formatting does not split it, and they keep their own text, format and place. An amount after a footnote marker is still not restyled, but a split one warns.
  • Without the option, the automatic red covers a colour written in the document (existing behaviour). The option turns off only the automatic red, so a colour written in the document (<span style="color:…">) shows as written. A link's colour stays in both cases.
  • Alignment and column widths are the same as without the option.
  • Without negative, a written △… is left exactly as written. Any other value, or negative without type: financial in the same spec, is rejected.

Table and figure numbers and cross-references

Give a table or figure an ID and the engine writes its caption as Word's Insert Caption command does: 표 1. Title, 그림 1. Description. The number is a Word SEQ field holding the number the engine worked out, and a body reference is a Word cross-reference (REF field) holding 표 1. After someone inserts another table in Word and updates fields, later numbers and references follow. Tables and figures without an ID render exactly as before.

tables:
  - id: tbl-results        # tbl-, then lowercase letters and digits; words joined by hyphens
    caption: 연도별 실적
    unit: 억원
![거래 구조도](structure.png){#fig-structure}

@tbl-results에서 보듯 매출이 늘었다. 구조는 @fig-structure 참조.
  • Tables take id: tbl-… in their table spec and need a caption. Figures take {#fig-…} at the end of an image file line of its own and need a description. A {#…} after an image inside a paragraph, list or table cell, or on an embedded Base64 image, numbers nothing and is reported. A chart takes id: fig-… in its chart block and needs a title: the title line becomes 그림 2. … and charts share the figure count with images. A chart that is not drawn (charts off) gets no number and references to it are reported. Diagrams are not numbered.
  • Tables and figures are counted separately from the start of the document, and only those actually drawn; there are no chapter numbers (표 2-1). The labels are 표 and 그림 in every profile.
  • @tbl-… and @fig-… become cross-references in paragraphs, lists, quotes, headings, table cells (HTML tables included) and table caption/unit/source/note text.
  • Reference grammar:
    • The character before @ must be the start of the text, whitespace, or an opening bracket or quote ((, [, 「, ", ...). An @ after a letter, digit, +, ., _ or - (an e-mail address such as user+@tbl-x.example) or after another @ is not a reference. Written right after any other character (@tbl-a,@tbl-b, @tbl-a~@tbl-b, note:@tbl-a) it is not a reference either and stays text, but when its ID is the ID of a table or figure in the document it was meant as one and is reported. Put a space before the @ (@tbl-a, @tbl-b), or write \@tbl-b to keep it as text. Frontmatter values shown as plain text are not reported this way.
    • tbl- and fig- are lowercase. @Tbl-a or @FIG-a is reported as a malformed reference.
    • Text inside a chart or diagram block is like a code block and holds no reference.
    • The ID is read whole, up to the last letter, digit, - or _, then checked. A malformed ID (@tbl-a-, @tbl-, @tbl-Results) is reported, never shortened to a valid prefix. A Korean particle, whitespace or punctuation may follow the ID directly (@tbl-results에서, (@tbl-results)).
    • An ID followed by . and a letter or digit (a domain such as @tbl-x.example) is not a reference.
    • Code spans and blocks, math ($…$), link destinations and an escaped \@ never hold a reference, wherever they stand.
    • The text is read as a reader sees it, across bold, italic and colour; an empty colour span adds nothing. An ID that formatting splits (@tbl-a**b**, @tbl-a<span …>b</span>) is reported, never resolved, and the domain rule applies to the whole visible ID (@tbl-a**b**.com is not a reference).
    • A heading is rendered without its ** markers but judged with them, like body text: ## @tbl-**a** is reported.
    • Term values ({{key}}) are never read as references, also in a heading that becomes the document title.
    • References are read in the text as parsed, so @**tbl-a**, an HTML &#64;tbl-a and a YAML escape for @ in a frontmatter value are read (and reported) like any other.
    • Text that is not read as a reference, and a reference that does not resolve, render exactly as written, as before the feature, private-use characters included: a run is split only around a reference that resolves.
  • Word does not update these fields on opening or print preview (checked with Word 16 on Windows); select all and press F9 after editing. The cached values are correct until then.
  • Korean Word has no built-in 그림 caption label. To continue figure numbers with Word's Insert Caption, create the label 그림 once (References › Insert Caption › New Label).
  • Strict mode rejects, wherever the grammar reads a reference, one to an unknown ID, a malformed one, one whose ID formatting splits (@tbl-a**b**), one inside link text, and one in an image description (inline and HTML data: images included), a footnote or a frontmatter value the document shows (below), where no Word field can go; the default mode keeps such text exactly as written and reports it. A repeated figure ID and a {#…} that numbers nothing are rejected in strict mode too and kept as text otherwise. Table spec id errors in shape, repetition or a missing caption reject the document in both modes, like other table spec errors. An id on a table with no columns, which is not drawn, is rejected in strict mode; the default mode reports it and gives the table no number.
  • Frontmatter values checked for references (they are written as text): the title and subtitle always, and the date in every profile but plain, as written before term values are inserted. Every other value only where the document shows it: on the IB cover report_type, sector, ticker, subject_company (or company), analyst, recipient, analysis_period, analysis_basis; in the title block sender.department, analyst, meeting_time, location, attendees (a letter: sender.organization, recipients, cc); in the letter closing attachments, sender.signatory (or sender.organization), document_no, sender.department, sender.contact, and letter.appendix_label at the head of the appendix; in the header sender.organization (or company) and version (not in a letter); on the disclaimer page company; in a term sheet version and the prepared_by, disclaimer and confidentiality-label texts. A value is read as it is shown (plain text; term-sheet texts as inline Markdown). report_type is shown in capitals and so never holds a reference. A value an IB profile reads from a leading body paragraph (**작성자:** …) is judged in that paragraph: a term value, an escaped @ or code there is not a reference, and one that resolves there is reported where the value is shown.
  • A reference that resolves changes nothing but its own text: an amount beside it in a table cell keeps the form it has without the ID, and the IB TOC preview keeps the heading as written with only the reference as 표 1.
  • docx-audit reports a reference whose target bookmark is missing as an issue and a stale reference or caption number (fields not yet updated) as a warning. Numbering order is judged only for SEQ sequences without switches or with \* ARABIC alone. Only the main body is checked (not headers, footers or footnotes).

Allowed asset folders, input limits and rejections

The image/logo path restriction changes earlier behaviour: a local image that previously loaded can now be rejected if it is outside the allowed folders. For a Markdown file, its own folder and subfolders are allowed by default. Markdown text or a stream without a source file, and a directly constructed document model, have no default allowed folder; the current working directory is not implicitly allowed.

An operator can add folders with repeatable --asset-root FOLDER options. The API equivalent is asset_roots, accepted by parse_markdown_file, MarkdownParser, IBDocumentRenderer.render and registry conversion calls; RenderOptions(asset_roots=(... ,)) also supports converter configuration. Parsed models carry their allowed folders through a separate render/registry step. Added folders include subfolders and cannot remove the default folder. Only operator CLI/API arguments can add folders or change limits; document content, frontmatter, house and theme files cannot do so.

uv run md-to-word job/draft.md output.docx --strict --asset-root shared-assets

Paths are checked after resolving relative components, symbolic links and junctions to their final location, before checking whether the file exists. An escaping ../, absolute or UNC path, or a link to an outside file is rejected. Absolute and UNC paths resolving inside an allowed folder are accepted, including the folder of a Markdown file on a network share. Original and percent-decoded path candidates receive the same check.

Asset or referencePath restriction
Body, reference-style, HTML and table-cell imagesApplies
Frontmatter style.logoApplies
Logo in a house file selected by document frontmatterApplies, even if the house file itself is elsewhere
Logo in a house file supplied directly by operator --house or API RenderOptions(house=...)Exempt; a frontmatter logo override remains restricted
data: / Base64 imagesNo path restriction; image size limits still apply
Frontmatter house: and theme: file paths themselvesNo path restriction
Local file hyperlinksNo path restriction; their file contents are not embedded

House logo paths remain relative to the house file; frontmatter logo paths are relative to the Markdown file. Without a source file, relative house/logo paths remain unsupported; absolute document-selected logos need an explicit allowed folder. Remote HTTP(S) images remain unsupported. Outside images are not read: normal mode leaves a body-image placeholder or omits a logo and warns with asset_outside_root; strict mode refuses to save.

The following limits stop conversion in both normal and strict modes, without creating a DOCX. MiB means 1,048,576 bytes; CLI values are integer counts, not unit-suffixed strings.

CodeMeasurementDefaultCLI option / InputLimits field
limit_input_bytesOriginal Markdown bytes16 MiB (16,777,216)--max-input-bytes / max_input_bytes
limit_table_cellsCells per table, including headers: rows × columns; expanded grid for HTML merges50,000--max-table-cells / max_table_cells
limit_list_depthNested list levels32--max-list-depth / max_list_depth
limit_image_bytesBytes per image or logo; decoded size for Base64 / data:20 MiB (20,971,520)--max-image-bytes / max_image_bytes
limit_image_pixelsWidth × height per image or logo50,000,000--max-image-pixels / max_image_pixels

Image limits apply to all sources, including logos from operator-supplied house files. Oversized Base64 is rejected from its encoded length before decoding. Options accept positive integers only; there is no unlimited value. Pass an InputLimits instance as the API limits argument (parser, renderer, registry or IBReportConverter), or through RenderOptions(limits=...). For example:

from input_safety import InputLimits
from md_parser import parse_markdown_file

model = parse_markdown_file(
    "job/draft.md",
    asset_roots=("shared-assets",),
    limits=InputLimits(max_table_cells=60_000),
)

The policy applies to md-to-word, ib-report, file/text/stream APIs, direct model rendering, the registry and batch conversion. Text inputs are measured as UTF-8 bytes. With --format or other conversion preprocessing, Markdown size is checked before cleanup and again before parsing the cleaned result. In a batch, an over-limit file fails while the other files continue; the overall exit status reports failure. Standalone md-format and docx-audit inputs are outside these size limits.

There are exactly six rejection codes: asset_outside_root and the five limit_* codes above. Each coded warning/issue starts with [code] , including inside combined strict-error messages; existing uncoded messages stay uncoded. API rejections derive from ConversionRejection (ValueError): StrictValidationError.codes lists the included codes and InputLimitError exposes code, limit and measured. Wrapped failures retain the rejection in __cause__. In the plugin runner's result.json, each coded issue also has its own diagnostic with that code and the full prefixed sentence as message; existing input_validation, structural_issue, exception-type and invalid_arguments entries remain, with strict rejections still reported as ValueError in the existing entry.

The plugin runner and portable converter always use strict mode and provide no option to add allowed folders or raise limits. Copy the needed images, house file and its logo into the job folder holding the draft (subfolders allowed), and reference them with relative paths. Keep real document workspaces outside the repository/plugin. For asset_outside_root, copy the needed files and correct the references. For a limit rejection, use the reported limit and measured value to reduce or split the input, table or image while preserving source facts. The portable window explains each code in Korean; the runner writes diagnostics to result.json and requires a new output directory for each attempt. Absolute launcher, draft and output-directory command-line paths remain valid.

Supported Markdown and limitations

  • Headings, paragraphs, emphasis, pipe tables, lists, blockquotes/callouts, local/base64 images, code blocks and existing diagram/LaTeX rendering.
  • Bullet markers are -, * and +. Headings go from # to ######; levels 5 and 6 use the level 4 style. A closed code fence keeps its text exactly, including blank lines at its end.
  • A backslash escapes any ASCII punctuation character (\#, \%, \*, \<). Code, link destinations and text between dollar signs ($5\%$) keep their backslashes.
  • Emphasis follows CommonMark's flanking rule: 2 * 3 * 4 and a note marker followed by a space (* 주요 매출처) stay literal.
  • HTML <table> blocks from document converters become Word tables: colspan/rowspan merge cells, block tags and <br> break lines, <b>/<i>/<code>/<sup>/<sub>, colour spans and <a href> format text, <img> becomes a cell image and nested tables are flattened into their cell. HTML text stays literal (it is never re-read as Markdown); {{key}} references are substituted. Rows that the first row's spans cover stay separate header rows (header_rows). Unclosed tables and text outside cells are reported; strict mode rejects them.
  • Images inside text and table cells (![alt](path)) are inserted inline and fitted to the cell. Percent-encoded image paths (a%20b.png) are found, and a standalone <img> line is an image.
  • An image's description (![description](path), <img alt="...">) becomes its Word alt text. An image inserted without one gets a warning naming its file (or embedded image) and its Word name (Picture 3); strict mode still saves and the document is unchanged. docx-audit warns for every picture in the body without alt text, including equations, diagrams and logos the engine draws, which have no description you can write.
  • External HTTP(S)/mailto links become Word hyperlinks. Local file links become hyperlinks too when the destination is in angle brackets, starts with a drive (C:/) or .//../, or ends in a document extension (.md, .docx, .xlsx, .pdf, .hwp(x), images...). Relative paths refer to the Markdown file's folder; a # after a document extension is a fragment. Absolute paths (C:/..., /...) are file names, so # and % in them are literal. When the CLI, IBReportConverter or the registry saves the DOCX, relative links are rewritten to reach the same file from the DOCX folder, and absolute paths inside the DOCX folder become relative links, so they open for colleagues when the folder is shared and do not reveal your local directory; other absolute paths stay file:/// links with a log warning. A document you save yourself keeps relative links against the Markdown folder.
  • Inline code is shown without its backticks, in the code font (CODE_FONT, default Consolas); its content stays literal (no emphasis, breaks, footnotes or term substitution) and is excluded from table number formatting.
  • Every profile turns off Word's automatic spacing between Korean and Latin text or digits, so SPC는, 제2종, 300억원 print tight.
  • Numeric single-line footnotes [^1] / [^1]: Note become native notes when referenced; no named or multiline footnotes.
  • Soft-wrapped paragraph lines merge with spaces. <br>, <br/>, <BR /> work inside paragraphs, emphasis, headings, lists and table cells. A trailing backslash also preserves a paragraph hard break. Escaped \<br> and code remain literal; link destinations are not rewritten. Trailing two spaces require the parser's opt-in legacy flag.
  • IB legacy reference-section extraction remains, but only actual reference labels trigger it. General documents keep References as ordinary content.
  • This is not a full CommonMark/GFM implementation, a financial calculation engine, a compliance validator, or a lossless layout converter. Raw HTML, complex nested Markdown and arbitrary Word templates are not guaranteed.
  • Math/diagram/chart output may be images, not editable equations/charts. New valuation models, native editable charts and PDF distribution are outside this release.
  • Update fields/TOC in Word if necessary. Pagination, font substitution and very tall/wide tables still require a visual review. Strict mode is not visual QA.

API

from md_parser import parse_markdown_file
from document_profiles import RenderOptions
from ib_renderer import IBDocumentRenderer

model = parse_markdown_file("input.md", profile="plain")
doc = IBDocumentRenderer(options=RenderOptions(strict=True)).render(model)
doc.save("output.docx")

Pass the same profile at parsing time to apply its parsing policy. Parsed models record that profile, and rendering under a different profile raises ValueError in both strict and non-strict modes: reparse the Markdown with the desired profile instead of silently losing transformed content. Hand-built models without parser provenance may select their rendering profile. The renderer copies its input model and uses request-local immutable styles. Use one renderer instance per concurrent job.

from converters import get_default_registry

registry = get_default_registry()
model = registry.convert("input.md", profile="business-report")
saved_path = registry.convert(model, output_format="docx",
                              output_path="output.docx", strict=True)

Only Markdown input and DOCX output are built in. Models live in document_model.py; legacy model imports from md_parser remain supported. ib_renderer and md_parser are split into internal files (ib_render_*.py, md_parse_*.py); import from ib_renderer and md_parser as before.

Validation and development

--strict rejects known input loss (e.g. extra table cells), invalid footnote references, element render errors and unresolved image placeholders before saving. Without strict mode the converter may emit a partial document with warnings. docx-audit reports structural observations and known problems as JSON; it never converts Word back to Markdown.

Audit warnings distinguish Normal-style pagination constraints from structural issues. pagination_marked_paragraphs counts effective keep-lines/keep-next/page-break-before settings, including table paragraphs and inherited styles; it is not a bullet count. Word may show these as nonprinting black squares when formatting marks are visible. Keep necessary heading pagination controls; do not strip every flag or silently change the user's Word display settings. visual_review: not_performed means that structural inspection did not review rendered pages.

uv sync --extra dev
uv run pytest tests/
uv run ruff check .
uv run ruff format --check .
uv run mypy .
uv build

CI runs these on Ubuntu and Windows with Python 3.12 and 3.13. Three further checks guard the output:

  • Word schema gate. A separate CI job renders every sample in strict mode and checks the documents with a pinned OOXML-Validator build; any error outside scripts/word_schema_exceptions.json fails the job. scripts/word_schema_validation.md explains the local run and the exception rule. Passing it is a structural result, not a visual review.
  • Snapshots. tests/test_sample_snapshots.py compares the parsed model and every XML part of every sample with stored snapshots; a missing snapshot fails. After an intended output change, run uv run pytest tests/test_sample_snapshots.py --snapshot-update, review the diff, and check the changed samples in Word.
  • Properties. tests/test_markdown_properties.py generates Markdown with fixed examples and checks that visible text and table cells survive, that code and escapes stay literal, and that a strict conversion either saves a document or ends in a documented rejection without leaving a file. Its one strict xfail records the intended tree-value emphasis inside code blocks. tests/test_config_properties.py applies the same save-or-reject check to generated house and theme file content and to YAML built with aliases, under a time limit.

Batch conversion: uv run md-to-word samples/profiles --batch. Optional clipboard cleanup: --format; optional DeepResearch cleanup: --deepresearch-cleaner auto. Preprocessors can change content, so review the cleaned input.

UTF-8/BOM, EUC-KR and CP949 Korean input is decoded deterministically before optional statistical detection. Local image paths resolve from the Markdown directory. In plain/office profiles, superscripts such as m^2^ remain text; use [^2] for a footnote.

Word page QA on Windows

With Microsoft Word installed, generate examples and render all pages as PNGs:

uv run md_to_word.py samples/profiles .dryforge/qa/docx --batch --strict
uv run md_to_word.py samples/qa .dryforge/qa/docx --batch --strict
powershell.exe -NoProfile -File scripts/word_visual_qa.ps1 -InputDirectory .dryforge/qa/docx -OutputDirectory .dryforge/qa/pages

The local QA script opens source DOCX files read-only, updates fields in QA copies, warms Word's page cache, and writes page PNGs plus manifest.json. It does not change the default printer or add-in settings. Output directories must be new or empty; existing evidence is never overwritten. Optional -ExpectedPages 2 requires every input to have two pages (omit for mixed page counts). A mismatch or source change produces a nonzero exit after recording the completed evidence.

The manifest is always an array and records Word version/build, timestamps, source/updated-DOCX/PNG SHA-256 hashes, actual/expected page counts, and visualReview: pending. A successful render does not mark visual review complete: inspect every PNG and record observations separately against the manifest hash. This is not unattended Office hosting or PDF delivery. See the September 15 Word QA record.

On Windows, pass Korean paths in quotes using the literal filesystem spelling. Markdown-escaped paths such as file\_draft.md are not the same as file_draft.md; do not blindly remove backslashes, since _draft.md could be a real child path. Resolve the actual file first; input/output paths are not guessed or rewritten by the CLI.

Migration from 1.x

  • Default ib-report and the existing Markdown→Word CLI stay available. Corrected empty cells, number formatting, CLI header/footer composition and disclaimer toggles intentionally change affected output.
  • Removed modules: word_to_md, word_parser, md_renderer, omml_latex, roundtrip_audit; removed built-ins: DocxInputConverter, MarkdownOutputConverter; removed command: roundtrip-audit.
  • Historical source is recoverable at commit d819bbb / local branch codex/archive-word-to-md-d819bbb. Use external tools for Word→Markdown; those tools are not dependencies of this engine.
  • Historical plans may discuss bidirectional conversion; this README and the September 2026 implementation plan supersede them.