PHPackages                             wp-php-toolkit/markdown - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wp-php-toolkit/markdown

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wp-php-toolkit/markdown
=======================

Markdown component for WordPress.

v0.8.1(1mo ago)04.6kGPL-2.0-or-laterPHPPHP &gt;=7.2

Since May 20Pushed 1mo agoCompare

[ Source](https://github.com/wp-php-toolkit/markdown)[ Packagist](https://packagist.org/packages/wp-php-toolkit/markdown)[ Docs](https://wordpress.github.io/php-toolkit/reference/markdown.html)[ RSS](/packages/wp-php-toolkit-markdown/feed)WikiDiscussions trunk Synced today

READMEChangelogDependencies (8)Versions (49)Used By (0)

   slug markdown   title Markdown   install wp-php-toolkit/markdown   credit\_title Built on league/commonmark   credit\_body Markdown parsing is delegated to &lt;a href="[https://commonmark.thephpleague.com/"&gt;&lt;code&gt;league/commonmark&lt;/code&gt;&lt;/a](https://commonmark.thephpleague.com/">league/commonmarkWordPress) block markup&lt;/a&gt;, in both directions.    see\_also    blockparser | BlockParser | Understand the block tree created from Markdown output.

 html | HTML | Rewrite rendered HTML fragments without using DOMDocument.

 dataliberation | DataLiberation | Turn Markdown folders into import/export streams.

    Bidirectional converter between Markdown and WordPress block markup. Useful for moving content between Markdown files and WordPress while preserving the structures both formats can express.

Why this exists
---------------

[](#why-this-exists)

Many publishing workflows start in Markdown: documentation sites, static-site generators, Git-backed editorial workflows, Obsidian vaults, and developer notes. WordPress stores editor content as block markup. Moving between those worlds by string replacement loses metadata and quickly breaks on lists, tables, code blocks, and frontmatter.

The Markdown component provides a structured bridge. `MarkdownConsumer` turns Markdown plus frontmatter into block markup and metadata; `MarkdownProducer` turns supported block markup back into Markdown. The conversion is meant for practical content workflows, not byte-identical round-tripping of every custom block attribute.

Markdown to blocks
------------------

[](#markdown-to-blocks)

Feed Markdown into `MarkdownConsumer`, get block markup back. The result is a `BlocksWithMetadata` object (defined in `WordPress\DataLiberation\DataFormatConsumer` — the shared shape every `DataFormatConsumer` in the toolkit emits) that holds both the rendered blocks and any frontmatter parsed from the document.

```
