markdown office

Markdown, into the file you actually send

A finished .docx or .pptx, from a Markdown file, in PHP. No Office installed, no headless browser, no export button.

What each one does

Markdown Word Markdown Presentation
Markdown → document .docx .odt .rtf .pptx
document → Markdown yes, for standard Markdown no — one direction only
Markdown dialect CommonMark + GitHub Flavored Slidev-inspired
Look and feel frontmatter + themes frontmatter + themes
Special features directives directives
What those are ::toc, :footnote ::click, :::click, ::column, ::note
What it will not do a :::toc body, a one-line code block's language, a theme in a .dotx a Slidev directive, --- as a rule, an image over 16 megapixels

Two of those lines are worth reading twice.

Word converts both ways. A .docx goes back to Markdown, and for standard Markdown it goes back well — headings, emphasis, code, lists and tables all survive. Directives are the exception and are written down rather than glossed over: a ::toc comes back as the text "Press F9 to build the table of contents", which is what the document actually said, and a :footnote[…] comes back as itself because it was never a footnote in the first place. See Round trips.

PowerPoint is one direction. There is no reader, no .pptx back to Markdown, and no plan to add one: a deck is a thing you present, and the interesting inverse problem — what someone edited in PowerPoint should become Markdown — is a different and much larger problem than the one this package solves.

The suite
Start here

Every example here is a real document

Each one is converted by the library it documents while this page is built, and can be downloaded and opened. If an example stops working, the build stops — which is how this site came to say that :footnote[…] produces no footnote.

Read it over HTTP

Nothing here needs a browser or a round trip. The same three files are at llms.txt, llms-full.txt and pages.json, and every page is available as Markdown at its own URL.

Requirements

PHP 8.2 or newer, with ext-dom, ext-gd and ext-zip — plus ext-mbstring for the Word half. ext-imagick is optional and buys SVG; without it an SVG is refused by name rather than quietly rasterised badly.

Two extensions are asked for by the dependency rather than by this code, and only matter when the extractions are compiled from source: ext-zip, which every normal PHP install bundles, and ext-xmlwriter, which PHPWord uses to write a document and which ext-xml does not provide. A from-source build that omits either produces an archive that reports its version and then cannot write anything.

The command line needs none of this if you take a release instead: each executable carries its own PHP. See the command line.

Every example on this page was built by the library it documents while this page was built. This page as Markdown.