Kai Ole Hartwig

sylius-markdown — Markdown from data, not from HTML.

If a client sends Accept: text/markdown, the storefront answers with Markdown. The document is built from entity data through a Twig template, not from rendered HTML — otherwise navigation, footer and cookie banner would end up in it. The listener runs before the controller, so generating the HTML is skipped entirely.

Deriving Markdown from HTML means shipping the footer with it

The shortest route to Markdown is to push the finished HTML page through a converter. What comes out contains the main navigation, the footer, the cookie banner and every teaser element — that is, everything that is identical on every page and therefore says nothing about this one page. Here the document is built from entity data through a Twig template instead. What ends up in the Markdown is a decision made by the template, not a by-product of the layout.

The listener runs before the controller. That is more than an optimisation: if it hooked into the response, the storefront would first have to render the complete HTML page only to throw it away afterwards — including all the Twig extensions and database queries that exist purely for navigation and peripheral areas. This way, generating the HTML is skipped entirely.

And it sits below the firewall, so that a Markdown request to /account/… is subject to the same access control as the HTML request. A listener above the firewall would be exactly what it sounds like: an Accept header as a way around authentication. Content negotiation changes how a resource is represented, never the question of who is allowed to see it.

The same access control as the HTML request

Sylius: 2.0+ · PHP: 8.2+ · Licence: MIT · Version: 1.0.0

Source code & documentation

Composer package

MIT · Sylius 2.0+ · PHP 8.2+

composer require koh/sylius-markdown

Built, tested and released under MIT. Public distribution via Packagist is being prepared (coming soon).

Part of the family

MIT

This package is part of koh/sylius-agent-ready — seventeen bundles that make a Sylius shop usable for AI agents. Each one works on its own.

To the overview
Part of the family