md-to-word
Compile a Markdown document into Word (.docx) that matches a declared format: typography, headings, native OMML equations, three-line tables, captions, cross-references, TOC field, per-section page numbers, CSL bibliographies, and pre/post-export quality gates. 把 Markdown 导出为符合规范的 Word:学位论文、期刊论文、技术报告、公文、说明书都适用;格式写在一份随稿件进 Git 的要求文件里。
Use when the user wants a .docx — a submission, a report, an official document, or just a readable copy — including 导出Word、文档转Word、转成Word、论文排版、公文排版、报告排版、prepare submission docx. Not for PDF, HTML or LaTeX output.
中文简介正在准备中。当前显示原文说明。
实测评分 未实测
查看安装方法包含的文件(200)
- SKILL.md10.8 KB
- .github/workflows/ci.yml2.0 KB
- .gitignore172 B
- demo/00_quickstart/format.txt1.4 KB
- demo/00_quickstart/hello.docx9.9 KB
- demo/00_quickstart/hello.md1.8 KB
- demo/00_quickstart/hello.pdf136.5 KB
- demo/00_quickstart/page-1.png199.7 KB
- demo/00_quickstart/README.md2.2 KB
- demo/01_chinese_thesis/figures/qa_pipeline.png118.2 KB
- demo/01_chinese_thesis/figures/system_architecture.png172.2 KB
- demo/01_chinese_thesis/format.txt3.6 KB
- demo/01_chinese_thesis/page-1.png164.6 KB
- demo/01_chinese_thesis/page-2.png47.8 KB
- demo/01_chinese_thesis/page-3.png178.1 KB
- demo/01_chinese_thesis/page-4.png169.5 KB
- demo/01_chinese_thesis/page-5.png133.8 KB
- demo/01_chinese_thesis/page-6.png217.6 KB
- demo/01_chinese_thesis/page-7.png180.8 KB
- demo/01_chinese_thesis/page-8.png91.1 KB
- demo/01_chinese_thesis/README.md5.2 KB
- demo/01_chinese_thesis/references.bib803 B
- demo/01_chinese_thesis/thesis_sample.docx285.8 KB
- demo/01_chinese_thesis/thesis_sample.md9.4 KB
- demo/01_chinese_thesis/thesis_sample.pdf672.4 KB
- demo/02_modern_report/figures/export_timing.png68.4 KB
- demo/02_modern_report/format.txt3.1 KB
- demo/02_modern_report/page-1.png287.8 KB
- demo/02_modern_report/page-2.png197.9 KB
- demo/02_modern_report/page-3.png230.7 KB
- demo/02_modern_report/page-4.png254.1 KB
- demo/02_modern_report/page-5.png40.1 KB
- demo/02_modern_report/README.md2.3 KB
- demo/02_modern_report/references.bib494 B
- demo/02_modern_report/report_sample.docx76.0 KB
- demo/02_modern_report/report_sample.md8.0 KB
- demo/02_modern_report/report_sample.pdf432.0 KB
- demo/03_english_paper/figures/pipeline.png97.8 KB
- demo/03_english_paper/page-1.png146.5 KB
- demo/03_english_paper/page-2.png87.9 KB
- demo/03_english_paper/paper.docx101.2 KB
- demo/03_english_paper/paper.md2.1 KB
- demo/03_english_paper/paper.pdf297.5 KB
- demo/03_english_paper/README.md912 B
- demo/03_english_paper/refs.bib524 B
- demo/make_demo_figures.py10.3 KB
- demo/README.md3.0 KB
- LICENSE1.0 KB
- MANIFEST.in463 B
- presets/en-nature.txt4.0 KB
- presets/zh-academic.txt4.5 KB
- pyproject.toml2.2 KB
- README_EN.md13.0 KB
- README.md11.4 KB
- references/design.md30.4 KB
- requirements.txt557 B
- resources/csl/acm-sig-proceedings.csl6.2 KB
- resources/csl/american-chemical-society.csl10.5 KB
- resources/csl/american-medical-association.csl11.3 KB
- resources/csl/apa.csl83.6 KB
- resources/csl/bmj.csl6.3 KB
- resources/csl/cell.csl5.3 KB
- resources/csl/chicago-author-date.csl163.8 KB
- resources/csl/china-national-standard-gb-t-7714-2025-numeric.csl16.8 KB
- resources/csl/chinese-gb7714-2015-author-date.csl16.3 KB
- resources/csl/chinese-gb7714-2015-numeric.csl15.8 KB
- resources/csl/elsevier-harvard.csl7.9 KB
- resources/csl/elsevier-vancouver.csl5.6 KB
- resources/csl/elsevier-with-titles.csl5.1 KB
- resources/csl/emerald-harvard.csl11.3 KB
- resources/csl/frontiers.csl5.9 KB
- resources/csl/harvard-cite-them-right.csl10.3 KB
- resources/csl/ieee.csl17.1 KB
- resources/csl/iso690-author-date-en.csl22.2 KB
- resources/csl/iso690-numeric-en.csl17.1 KB
- resources/csl/modern-language-association.csl43.3 KB
- resources/csl/multidisciplinary-digital-publishing-institute.csl9.3 KB
- resources/csl/nature.csl6.3 KB
- resources/csl/sage-vancouver.csl6.5 KB
- resources/csl/science.csl7.7 KB
- resources/csl/springer-basic-author-date.csl9.5 KB
- resources/csl/springer-lecture-notes-in-computer-science.csl5.8 KB
- resources/csl/springer-mathphys-brackets.csl5.6 KB
- resources/csl/springer-vancouver.csl7.0 KB
- resources/csl/the-lancet.csl6.2 KB
- resources/pure_modern_base.docx8.1 KB
- scripts/acceptance.sh2.4 KB
- scripts/check_md.py1.7 KB
- scripts/create_pure_modern_base.py22.2 KB
- scripts/export.sh1.9 KB
- scripts/generate_template.py584 B
- scripts/normalize_csl.py5.1 KB
- scripts/read_reference_docx.py597 B
- scripts/README.md2.8 KB
- scripts/render_via_word.sh369 B
- src/md_to_word/__init__.py1.7 KB
- src/md_to_word/__main__.py167 B
- src/md_to_word/audit/__init__.py260 B
- src/md_to_word/audit/inspector.py32.9 KB
- src/md_to_word/audit/postflight.py2.2 KB
- src/md_to_word/cli.py11.9 KB
- src/md_to_word/config.py3.3 KB
- src/md_to_word/i18n.py77.8 KB
- src/md_to_word/model/document.py7.6 KB
- src/md_to_word/model/reader.py28.1 KB
- src/md_to_word/pipeline.py17.6 KB
- src/md_to_word/preprocessor/__init__.py168 B
- src/md_to_word/preprocessor/blocks.py5.3 KB
- src/md_to_word/preprocessor/cleaner.py858 B
- src/md_to_word/preprocessor/markers.py3.3 KB
- src/md_to_word/presets/en-nature.txt4.0 KB
- src/md_to_word/presets/zh-academic.txt4.5 KB
- src/md_to_word/resources/csl/acm-sig-proceedings.csl6.2 KB
- src/md_to_word/resources/csl/american-chemical-society.csl10.5 KB
- src/md_to_word/resources/csl/american-medical-association.csl11.3 KB
- src/md_to_word/resources/csl/apa.csl83.6 KB
- src/md_to_word/resources/csl/bmj.csl6.3 KB
- src/md_to_word/resources/csl/cell.csl5.3 KB
- src/md_to_word/resources/csl/chicago-author-date.csl163.8 KB
- src/md_to_word/resources/csl/china-national-standard-gb-t-7714-2025-numeric.csl16.8 KB
- src/md_to_word/resources/csl/chinese-gb7714-2015-author-date.csl16.3 KB
- src/md_to_word/resources/csl/chinese-gb7714-2015-numeric.csl15.8 KB
- src/md_to_word/resources/csl/elsevier-harvard.csl7.9 KB
- src/md_to_word/resources/csl/elsevier-vancouver.csl5.6 KB
- src/md_to_word/resources/csl/elsevier-with-titles.csl5.1 KB
- src/md_to_word/resources/csl/emerald-harvard.csl11.3 KB
- src/md_to_word/resources/csl/frontiers.csl5.9 KB
- src/md_to_word/resources/csl/harvard-cite-them-right.csl10.3 KB
- src/md_to_word/resources/csl/ieee.csl17.1 KB
- src/md_to_word/resources/csl/iso690-author-date-en.csl22.2 KB
- src/md_to_word/resources/csl/iso690-numeric-en.csl17.1 KB
- src/md_to_word/resources/csl/modern-language-association.csl43.3 KB
- src/md_to_word/resources/csl/multidisciplinary-digital-publishing-institute.csl9.3 KB
- src/md_to_word/resources/csl/nature.csl6.3 KB
- src/md_to_word/resources/csl/sage-vancouver.csl6.5 KB
- src/md_to_word/resources/csl/science.csl7.7 KB
- src/md_to_word/resources/csl/springer-basic-author-date.csl9.5 KB
- src/md_to_word/resources/csl/springer-lecture-notes-in-computer-science.csl5.8 KB
- src/md_to_word/resources/csl/springer-mathphys-brackets.csl5.6 KB
- src/md_to_word/resources/csl/springer-vancouver.csl7.0 KB
- src/md_to_word/resources/csl/the-lancet.csl6.2 KB
- src/md_to_word/resources/guide.md10.1 KB
- src/md_to_word/resources/manual_en.md48.5 KB
- src/md_to_word/resources/manual.md39.0 KB
- src/md_to_word/resources/pure_modern_base.docx8.1 KB
- src/md_to_word/resources/render_via_word.sh8.0 KB
- src/md_to_word/scaffold.py3.2 KB
- src/md_to_word/spec/__init__.py718 B
- src/md_to_word/spec/constants.py8.5 KB
- src/md_to_word/spec/models.py1.8 KB
- src/md_to_word/spec/parser.py36.0 KB
- src/md_to_word/spec/presets.py693 B
- src/md_to_word/spec/serializer.py6.1 KB
- src/md_to_word/status.py455 B
- src/md_to_word/template/__init__.py238 B
- src/md_to_word/template/builder.py1.1 KB
- src/md_to_word/template/extractor.py29.4 KB
- src/md_to_word/template/generator.py73.8 KB
- src/md_to_word/transform/__init__.py233 B
- src/md_to_word/transform/bibtex.py10.5 KB
- src/md_to_word/transform/citations.py34.3 KB
- src/md_to_word/transform/csl_clean.py1.9 KB
- src/md_to_word/transform/disambiguation.py4.3 KB
- src/md_to_word/transform/mathml2omml.py21.8 KB
- src/md_to_word/utils/__init__.py0 B
- src/md_to_word/utils/docx_zip.py1.2 KB
- src/md_to_word/utils/pdf_figure.py4.1 KB
- src/md_to_word/utils/skill_utils.py34.4 KB
- src/md_to_word/utils/typography.py1.8 KB
- src/md_to_word/validator/__init__.py195 B
- src/md_to_word/validator/check.py29.5 KB
- src/md_to_word/visual_qa/__init__.py209 B
- src/md_to_word/visual_qa/word_pdf.py1.7 KB
- src/md_to_word/writer/__init__.py197 B
- src/md_to_word/writer/docx_writer.py47.9 KB
- tests/fixtures/manuscript.md284 B
- tests/fixtures/refs.bib120 B
- tests/golden/manuscript_zh.json666 B
- tests/test_audit_citation_ranged.py2.7 KB
- tests/test_audit_lists_tables.py7.1 KB
- tests/test_audit_math_cases.py6.6 KB
- tests/test_bibtex.py2.7 KB
- tests/test_bilingual_spec.py5.6 KB
- tests/test_bilingual_vocabulary.py3.7 KB
- tests/test_citation_details.py11.4 KB
- tests/test_csl_library.py2.5 KB
- tests/test_demo_coverage.py2.6 KB
- tests/test_demos.py2.3 KB
- tests/test_disambiguation.py6.7 KB
- tests/test_document_model.py7.7 KB
- tests/test_docx_writer.py20.0 KB
- tests/test_error_paths.py8.7 KB
- tests/test_golden_output.py2.3 KB
- tests/test_i18n.py10.2 KB
- tests/test_line_breaks.py4.1 KB
- tests/test_lists.py3.8 KB
- tests/test_manual.py5.7 KB
- tests/test_markdown_dialects.py3.8 KB
- tests/test_math_coverage.py3.6 KB
- tests/test_pdf_figure.py5.8 KB
SKILL.md(原文)
安装前可以查看交给 AI 代理的指令内容。
Markdown → compliant Word
Turns a Markdown manuscript into a .docx whose typography comes from a declared format file. The
engine is deterministic — the same manuscript and the same declarations produce a byte-identical
file on every run — so do not substitute a hand-written python-docx script; run this pipeline.
Read this before the first run. The flags are not enough to drive it: the manuscript has a
contract (§2) and the format file has a closed vocabulary (§3), and neither can be guessed from
--help. Work through §1 once, then the commands are enough for everything after. An identical
copy ships inside the package as guide.md (md-to-word --guide); reading one copy suffices.
The facts live in the manual. This file is the order of work. md-to-word --contract prints the
manual's absolute path (Chinese or English, following the manuscript), the built-in preset paths and
a one-screen contract summary. When a spelling is not certain, read the manual rather than guess:
every word outside the vocabulary is a hard error with a line number.
1. The work, in order
- Normalize the manuscript (pasted text,
.txt,.md, an old.docx, a PDF) to the contract in §2. Write a new file; never edit the user's original in place. - Decide the format (§3): built-in preset, an edited copy of one, or the requirements file the user supplied.
- Export (§4).
- Read the gates (§4), fix the reported lines, export again. Repeat until the exit code is
0. - Report (§5): what format was applied, what the run warned about, and that the layout still needs a look in Word.
Nothing here accepts arbitrary Markdown and returns a finished document: a preset supplies formatting, not missing structure. Pre-flight stops with a line number instead of emitting a document that looks acceptable while its formatting was never mapped.
2. The manuscript contract
Headings — #, ##, ###, consecutive and unskipped; a heading that carries its own number
(1., 2.1) needs as many # as its number has levels. Heading levels are set by # only.
Style lines — a line starting with %% sets that paragraph's style. One line is one paragraph,
ended by a blank line, no closing fence. Names come from a closed list, valid in either language;
these are the ones that come up in almost every document:
| Style line | Sets |
|---|---|
%% Title … / %% 文档标题 … | the document title |
%% Author … / %% 作者 … | author line |
%% Abstract Title … / %% 摘要标题 … | the "Abstract" heading |
%% Abstract … / %% 摘要 … | abstract body |
%% Keywords … / %% 关键词 … | keywords |
%% Table Caption … / %% 表题 … | caption above a table |
%% Table Note … / %% 表注 … | note below a table |
%% Image Caption … / %% 图片题注 … | caption for a figure |
%% References Title … / %% 参考文献标题 … | the bibliography heading |
Full list: manual §3.4.
Paragraphs — one line is one paragraph; consecutive lines are never joined. A break inside a paragraph (an address, verse, a long title) is written as a backslash or two spaces at the end of the line: it becomes a line break within the same paragraph, not a new paragraph. Suspected wrapping — a plain line without closing punctuation followed by another plain line — is reported as a warning with the line numbers; short paragraphs written one per line are correct as they are.
Title, author, abstract and keywords go in the body as style lines, never in YAML — their position on the page is the author's decision and YAML has no position. Pre-flight blocks those keys and prints the exact line to write instead.
YAML holds only position-independent configuration: bibliography:, csl:, crossref:
(link-citations: false drops the in-text hyperlink).
Equations — $$...$$ {#eq-name} on its own line, referenced as @eq-name. Chinese manuscripts
get 「式/图/表」 prefixes and (1)numbering, English ones Equation/Figure/Table and (1);
crossref: chapters: true switches to per-chapter numbering. \tag{} is blocked.
Citations — [@key] parenthetical, @key narrative, resolved from bibliography: + csl:. A
.bib is mandatory once the manuscript cites: handwritten reference lists are not supported, and
[@key] without bibliography: would be printed literally.
Figures and tables — {width=13cm}, caption in its own %% Image Caption
paragraph; table caption above, note below. Do not put {#fig-...} labels on images. Column widths
follow the separator row's dash lengths.
Block markers — three, each on its own line with blank lines around it: {{< pagebreak >}},
{{< toc >}}, {{< section page_number=lowerRoman start=1 >}} (Chinese parameters 页码= 起始=
also work). A section marker closes the section above it; never add a page break next to one.
Unsupported Markdown is blocked with a replacement, never printed literally — the list is manual §2.8.
3. The format requirements file
- Starting from nothing —
md-to-word initwrites a complete preset copy plus a one-page manuscript that exports as-is. Useful when the user has no format file and no template. - Built-in preset —
zh-academicoren-nature. Use as-is when the user gave no detailed spec; the preset is a complete, valid format, not a provisional default. - Copy and edit a preset — change only the lines the user mentioned. Field order is fixed: font, size, bold, italic, alignment, line spacing, space before, space after, indent. Every style line must be complete; missing fields are errors.
- Reverse-engineer a target
.docx—md-to-word-template target.docx -o format.txt, then work through the "to confirm" list at the end of the draft.
Each property has exactly one accepted spelling, plus its Chinese or English counterpart; anything
else is a hard error with a line number (manual §3.1). format.txt in these instructions means the
format requirements file — any filename works, -r takes it.
Citation style comes from csl: with a bundled name (manual §7) or a path to the user's own CSL.
Without csl:, Chinese manuscripts get GB/T 7714 numeric and everything else APA 7th.
Without -r the only file picked up is one named exactly format.txt beside the manuscript;
anything else there is ignored and named in a reminder. With no format.txt, the preset follows the
manuscript's language.
4. Export, then the gates
md-to-word manuscript.md -o manuscript.docx # preset by language
md-to-word manuscript.md -r format.txt -o manuscript.docx # explicit format
md-to-word --guide # this file, printed (pip-only entry)
md-to-word manuscript.md --contract # contract + guide, manual and preset paths
Run every command from the manuscript's directory: relative image and .bib paths resolve against
it. Add --pdf (macOS with Word) to expand fields and spot-check the result.
Add --json whenever the result has to be read back programmatically: stdout then carries one JSON
object — ok, returncode, input, output, pdf, lang, messages, errors — while progress
logs stay on stderr. The keys are fixed; the sentences inside them follow the manuscript's language.
Two gate levels, split by "would the mistake be visible afterwards" (criteria: manual §5):
- Blocking — invisible afterwards (dropped content, literal syntax, unmapped formatting); fix the line, never
--no-check. - Warning — visible but non-compliant (over-wide image, distant caption, skipped level); report it.
Exit codes: 0 every gate passed; 1 manuscript, gate or dependency problem; 2 a usage error
(bad flags or a missing argument); 3 the .docx was written but the optional --pdf proof was
skipped. Messages follow the manuscript's language.
5. Verify before delivery
- Confirm the
.docxexists and the command exited0. - Report the preset or requirements file, the citation style, and anything the run warned about.
- Say plainly that the layout still needs a manual check in Word. The engine verifies text and structure; row heights, column widths and where equations and captions settle are only visible in a real renderer.
- With a TOC,
{style-title}headers or per-section page numbers, run once with--pdfand check the first page, the widest table, an equation-heavy page and the references.
6. Boundaries
- No custom cover pages, merged cells, multi-column text, inline text colour or text-wrapped figures. Export the body, then complete those in Word.
- Only equation cross-references are supported (
{#eq-x}+@eq-x); figure and table numbers are typed into the caption. - Sum and integral limits stay to the right of the symbol in numbered equations (Word stacks limits only in display math). Content and symbols are correct; only the arrangement differs.
- TOC page numbers and chapter headers are Word fields; Word asks once whether to update them.
Full statements: manual §6 (limits) and §8 (symptom → fix).
7. Scope
This skill compiles a finished manuscript into a .docx and nothing else. Drafting, rewriting,
polishing, searching for sources and verifying reference metadata belong to whatever writing tools
the user already works with: take the Markdown they hand you, produce the .docx, return it. The
interface in both directions is a Markdown file plus a format.txt.
8. What this file may rely on
- the commands
md-to-word,md-to-word-templateandinit; every flag named in this file (-o,-r,--preset,--contract,--guide,--version,--json,--pdf,--lang) keeps its name and meaning - exit codes
0/1/2/3, and the JSON keys under--json - the manuscript contract in §2, the vocabulary in §3, the preset names
zh-academicanden-nature, and the fixed file nameformat.txt
Everything else — message wording, the layout inside the installed package, the version number — may
change. Never parse the prose of a message: pass --json and read the keys.
评价
还没有评价。欢迎分享你的使用感受。
评论
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。