Search by

qoliber / markdown-content

qoliber

Qoliber Markdown Content - serves storefront pages as Markdown on the same URL when a client sends Accept: text/markdown, while browsers keep receiving HTML

Package info

github.com/qoliber/markdown-content

Documentation

Type:magento2-module

pkg:composer/qoliber/markdown-content

Statistics

Installs: 1

Dependents: 2

Suggesters: 1

Stars: 0

Open Issues: 0

1.0.0 2026-11-30 11:51 UTC

This package is auto-updated.

Last update: 2026-11-30 12:04:17 UTC


README

License: MIT Packagist

Serves storefront pages as Markdown, on the same URL, to clients that ask for it with Accept: text/markdown. Browsers keep receiving HTML.

AI agents and coding assistants read pages far more cheaply as Markdown: a 100 KB product page becomes a few kilobytes of text with the title, price, stock, description, attributes and links intact.

curl -H 'Accept: text/markdown' https://shop.example/joust-duffle-bag.html
HTTP/2 200
content-type: text/markdown; charset=utf-8
vary: Accept
cache-control: no-store, private
x-markdown-tokens: 856

---
title: "Joust Duffle Bag"
description: "The sporty Joust Duffle Bag can't be beat ..."
url: "https://shop.example/joust-duffle-bag.html"
lang: "en"
---

# Joust Duffle Bag

$34.00

In stock

**SKU** 24-MB01

Contents

Requirements

  • Magento Open Source 2.4.6 or later, or Mage-OS
  • PHP 8.1 to 8.5
  • league/html-to-markdown and qoliber/tsuku 1.5 (installed by Composer)

Tested on these combinations, with the Luma theme and a second store view, with the built-in page cache and behind Varnish 7.5:

Magento PHP
2.4.6-p15 8.1
2.4.7-p10 8.2
2.4.8-p5 8.4
2.4.9 8.5
Mage-OS 4.0.0 8.4

The same suite has also been run against a Hyvä store view (it passed on Magento 2.4.8); Test/Compat/run.sh --hyva repeats that.

Magento 2.4.7 needs a word. Its quote validator builds a REST response object, and that object rejects an Accept header that names neither JSON, XML nor a wildcard, as Accept: text/markdown does. Wherever the validator is constructed the request then ends in HTTP 500, with or without this module: on the cart always, and on every page of a store that runs Magewire, which Hyvä Checkout installs. The module contains a guard for it, so no patch is needed.

Installation

composer require qoliber/markdown-content
bin/magento setup:upgrade
bin/magento setup:di:compile   # production mode only
bin/magento cache:enable qoliber_markdown_content
bin/magento cache:flush

Run setup:upgrade in developer mode too, also when you update the module. It clears Magento's generated code, and the module's plugins only take effect once that code is generated again.

cache:enable switches on the module's own cache type, Markdown Content. Magento adds a new cache type switched off. The module works without it, but then converts a page on every Markdown request instead of once.

First steps

  1. Open Stores → Configuration → Qoliber → Markdown Content and set Enable Markdown Responses to Yes. The setting is per store view.

  2. Refresh the Page Cache under System → Cache Management. Pages cached before the module was switched on are served as HTML until then.

  3. Ask for a page as an agent would:

    curl -s -D - -H 'Accept: text/markdown' https://shop.example/any-product.html

    The headers show content-type: text/markdown; charset=utf-8 and the body is the page as Markdown. The same command without the header returns the HTML page.

  4. Behind Varnish or a CDN, add the bypass rule from Caching and deployment. Without it agents mostly receive HTML.

Configuration

All settings are per store view.

Setting Default What it does
Enable Markdown Responses No Turns negotiation on for the store view.
Excluded Page Types none Every page type an installed module declares is served as Markdown unless it is selected here.
Serve Signed-in Customers No By default only visitors who are not signed in receive Markdown; a signed-in customer keeps receiving HTML. Turn it on for a store whose catalog requires a login.
Content to Convert Main content only Main content only converts the page's main area. Whole document also includes the header, navigation and footer and takes several times longer.
Include Images Yes Keeps images as Markdown image links. Turn off for the smallest output.
Additional Elements to Remove empty One selector per line: a tag, .class, #id, [attribute], [attribute=value], or a combination of them. For example, .product-info-stock-sku leaves the stock and SKU block of a Luma product page out. Combinators (div p, ul > li) and a lone * are not supported; such a line is ignored.
Maximum HTML Size (KB) 2048 Larger pages are served as HTML. At most 4096: conversion time and memory grow with the page.
Add Metadata Header Yes Starts the document with title, description, image, URL and language as YAML front matter.
Append Structured Data No Appends the page's JSON-LD as a code block.
Send Token Estimate Header Yes Adds x-markdown-tokens, estimated as bytes ÷ 4.
Templates: Product, Category, CMS Pages, Home Page Converted from the Page From a Template writes the page type's Markdown with the template below it, or with the shipped one when it is empty. See Markdown from templates.

When each change takes effect:

Change Takes effect
Switching the module off, excluding a page type At once, also for cached pages.
Switching the module on, removing a page type from the excluded list After the Page Cache is refreshed. Magento marks it as invalidated to remind you.
Every other setting At once.

Markdown from templates

Instead of converting a page's HTML, the module can write its Markdown from a template, with the store's data. The output then no longer depends on the theme, and it can say things the page does not show, such as every variant of a configurable product with its price and stock.

  • Per page type and store view: Stores > Configuration > Qoliber > Markdown Content > Templates. Set Product Pages, Category Pages, CMS Pages or Home Page to From a Template. With the template field left empty, the template the module ships is used.
  • Per CMS page or category: the AI Markdown tab of its form: Use the Store View Setting, Converted from the Page, From a Template (a template of its own; empty uses the store view's) or No Markdown (HTML Only). A category's settings can differ per store view; Same as All Store Views removes a store view's own. Preview Markdown renders the template as typed.
  • In a theme: override Qoliber_MarkdownContent::markdown/product.tsuku (also category.tsuku, cms_page.tsuku) at app/design/frontend/<Vendor>/<theme>/Qoliber_MarkdownContent/templates/markdown/.

The metadata header and structured data settings apply to template output as to converted pages. A template is checked when it is saved; one that cannot be rendered on the storefront gives the page converted from its HTML instead, and the problem is logged.

Templates are written in Tsuku:

# @markdown(product.name)

- **Price:** {product.price}@if(product.regular_price) (regular price {product.regular_price})@end
- **Availability:** {product.stock.label}

@for(product.variants as variant)
- @markdown(variant.label): {variant.price}, {variant.stock}
@end

@cms_block("shipping-information")
Variables Fields
product id, name, sku, type, url, description, short_description (both as Markdown), meta_title, meta_description, price (as displayed), price_value, price_incl_tax, price_excl_tax, regular_price (when it sells below it), currency, tier_prices (qty, price, saving_percent), in_stock, stock (in_stock, label), image, images (url, label), attributes (code, label, value) and attribute.<code> for attributes Visible on Catalog Pages on Storefront, categories (name, url), options and variants of a configurable product (sku, name, label, options, price, in_stock, stock), bundle_items (title, required, products), grouped_items, rating (value, percent, count), reviews (approved: title, text, author, rating, date), related (name, sku, url)
category id, name, url, description, meta_title, meta_description, image, breadcrumbs, children, products (the first page in category order: name, sku, url, price, in_stock), product_count
cms_page id, identifier, title, content_heading, content (as Markdown, widgets rendered), meta_title, meta_description, url
store name, store_view, code, url, currency, locale, language, address, phone, hours, email, vat_number
page url, type
Functions
@page_content() The page converted from its HTML, as without a template.
@cms_block("identifier") An active CMS block of the store view, as Markdown.
@markdown(value) Prints a value so Markdown shows it as written (*, _, [, # and line starts escaped).
Tsuku's own @upper(), @join(), @number(), @length() and the others of the Tsuku documentation.

A line starting with @# is a comment. A template reads only the data above: never a method of a Magento object, never a setting the storefront does not show, and never more than its render budget (1 MB of output, 20,000 loop passes, 5 seconds). Kept Markdown records the template it was made with and the cache tags of the data it read: a changed template, product, category, CMS page or block gives new Markdown at once.

Permissions: Edit the AI Markdown of CMS Pages and Categories shows the tab, Preview AI Markdown its preview button (System > Permissions > User Roles > AI Markdown).

Which requests get Markdown

A GET or HEAD request gets Markdown when its Accept header names text/markdown with a quality above zero and does not want HTML more:

Accept Response
text/markdown Markdown
text/markdown, text/html;q=0.9, */*;q=0.8 Markdown
text/markdown, text/html, */* Markdown (a tie goes to the type that was named)
text/markdown;charset=utf-8 Markdown
text/html, text/markdown;q=0.5 HTML
text/markdown;q=0 HTML
text/markdown;charset=iso-8859-1 HTML (Markdown is served in UTF-8 only)
*/*, text/*, or no header HTML

Other media type parameters, such as variant, are not compared. A header that cannot be read, for example with a quoted parameter that is never closed, gets HTML. No other request header can switch the representation.

Three more conditions apply:

  • The page: only pages Magento shares between all visitors are converted. Out of the box these are the home page, CMS pages, category pages, product pages, search results and advanced search results. Cart, checkout and customer account pages always stay HTML, as do redirects, error pages and API responses. So does Magento's contact form: its captcha block makes the page uncacheable, and an uncacheable page is never converted.
  • The visitor: a signed-in customer receives HTML unless Serve Signed-in Customers is on. This holds for a page rendered for them and for a page served from the page cache.
  • The conversion: when a page is over the size limit, or conversion fails or yields nothing, the HTML page is served. Conversion errors are logged as warnings; pages skipped for size or lack of content are noted in the debug log.

A HEAD request is answered with the headers of what the same GET returns, including x-markdown-tokens.

How it works

  1. While a page is rendered, a plugin marks the response when a module declared the page type, the merchant did not exclude it, and its layout is cacheable. The mark is a response header that Magento's page cache stores with the page; it is removed before the response is sent.
  2. Just before the response is sent, an observer checks the mark, the Accept header and the visitor. For a Markdown request it converts the HTML: reads the page metadata, selects the main content, removes scripts, form controls and theme noise, converts what is left, and tidies the result.
  3. The Markdown is kept in a cache type of its own, Markdown Content, as one entry per page and kind of visitor, under the page's own cache tags. The same page is converted once; later requests read the kept Markdown.

The page cache therefore holds one HTML copy of each page, the Markdown cache one Markdown document made from it, and it does not matter whether a browser or an agent asks first:

Request Page cache Markdown cache Response
A browser visits a page for the first time miss, page stored not touched HTML
An agent asks for the same page hit miss, Markdown stored Markdown
The agent asks again hit hit Markdown
The browser visits again hit not touched HTML

In developer mode Magento reports the first column in X-Magento-Cache-Debug, and this module the second in X-Qoliber-Markdown-Cache, as HIT or MISS.

Caching and deployment

Setup What to do Behaviour
Built-in page cache Enable the Markdown Content cache type The page is rendered once and converted once. Both formats carry Vary: Accept.
No page cache Nothing Every request renders the page, and every Markdown request converts it.
Varnish Enable the Markdown Content cache type and add the rule below Varnish stores the HTML and answers browsers. A Markdown request is passed to Magento, which renders and converts the page once and answers every later request from the kept Markdown, without rendering. Without the rule, Varnish answers from its cache whenever it has the page, so agents get Markdown only for pages it has not cached.
CDN that caches HTML Add a rule that bypasses the cache when Accept contains text/markdown As for Varnish.

Markdown is always sent with Cache-Control: private, no-store and without the page's Expires, so no cache between Magento and the client ever stores it and a browser can never receive it.

Varnish

The rule goes inside vcl_recv, just before its final return (hash);:

if (req.method ~ "^(GET|HEAD)$" && req.http.Accept ~ "(?i)text/markdown") {
    return (pass);
}

Test/Varnish/run.sh runs the module's Varnish tests against a Varnish 7.5 with Magento's own VCL plus this rule: both request orders for product, category and CMS pages, search results, HEAD, a saved product, and a Page Cache refresh.

Behind Varnish, Magento's own page cache is off. The first Markdown request for a page renders and converts it; the Markdown is then kept, so later requests cost a cache read and no rendering. The HTML that Varnish stores carries no Vary: Accept, which would split Varnish's cache by browser. Magento's VCL does not store search pages, so a browser's search is rendered each time; the Markdown of a search is kept all the same.

If agents request many different pages, limit the rate of requests that carry Accept: text/markdown at the edge, as you would for any traffic Varnish cannot answer.

Compression

nginx compresses only the media types listed in its gzip_types directive, and Magento's sample configuration does not list text/markdown. Add it there to send Markdown compressed.

The Markdown Content cache type

Converted Markdown has a cache type of its own, listed under System → Cache Management as Markdown Content (qoliber_markdown_content), next to Page Cache and Blocks HTML output.

bin/magento cache:status                              # shows whether it is enabled
bin/magento cache:enable qoliber_markdown_content
bin/magento cache:clean qoliber_markdown_content
State Behaviour
Enabled, with the built-in page cache or Varnish A page is converted on its first Markdown request and read from this cache afterwards.
Disabled Every Markdown request converts the page again; behind Varnish it also renders it again. Everything else works the same.
Enabled, without any page cache Nothing is stored: every request renders the page anew, and nothing would ever drop what was kept.

There is one entry per page address and kind of visitor (store view, currency, customer group), the same way Magento's page cache tells visitors apart. A changed setting takes effect at once. An entry lives as long as the page cache keeps a page.

Cache tags and cleaning

Every Markdown entry is saved under the cache tags of the page it was made from, the ones Magento collects from the page's blocks (cat_p_12, cat_c_4, cms_p_5, ...). Whatever makes Magento drop a page drops its Markdown too:

Action Page cache Markdown cache
A product, category, CMS page or block is saved, or reindexed Pages that show it are dropped The Markdown of those pages is dropped
Refresh Page Cache, cache:clean full_page Emptied (Varnish is purged) Emptied too
cache:clean qoliber_markdown_content Untouched Emptied; each page is converted again on its next Markdown request
Flush Magento Cache, cache:clean, cache:flush Emptied Emptied
Any other single cache type is cleaned Untouched Untouched

So the Markdown of a page follows its HTML without anything to configure, and a merchant who refreshes the Page Cache renews both formats at once.

With the built-in page cache there is a second safeguard: kept Markdown is only served when it was made from exactly the HTML that is being served. If a page changed in a way its cache tags did not announce, the Markdown is converted again instead of being served stale.

Clean the Markdown Content cache yourself after you change the conversion rules in etc/di.xml, because kept Markdown was made with the old rules.

Store views, currencies and customer groups

Each store view has its own addresses, so its Markdown is its own: links and the url of the metadata header point into that store view, lang is the language its pages declare, and prices are formatted for its locale. All settings are per store view, so Markdown can be on in one store view and off in another.

Within a store view, Markdown is kept apart for visitors Magento keeps apart: another currency or, where signed-in customers are served, another customer group has its own entries, as it has its own pages in the page cache.

Prices and tax

The Markdown shows the prices the store shows: excluding tax, including tax, or both, following Display Product Prices In Catalog. When the store shows both, Luma prints the labels through its stylesheet only; the module writes them out, so the Markdown reads Incl. Tax: $36.81 and Excl. Tax: $34.00 instead of two unnamed prices.

Adding your own pages

Any module can make its storefront pages available in Markdown. It takes one XML file and no PHP.

1. Declare the page

Create etc/markdown_content.xml in your module. It belongs in etc/ itself, not in etc/frontend/:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Qoliber_MarkdownContent:etc/markdown_content.xsd">
    <page id="blog_post_view" label="Blog Posts"/>
</config>
Attribute Required Meaning
id yes Full action name of the controller that renders the page: <route id>_<controller>_<action>, in lower case. It is also the name of the page's layout handle file, here blog_post_view.xml. A controller in a subdirectory adds a part, as in catalog_product_compare_index.
label no Name merchants see under Excluded Page Types. Defaults to the id. To translate it, add it to your module's i18n files.
disabled no true withdraws a page that another module declared.

One declaration covers every URL the controller serves, so one line is enough for all blog posts.

2. Clean the caches

bin/magento cache:clean config full_page

Both are needed. Declarations are read with the configuration, and a page that was cached before it was declared stays HTML until the page cache drops it.

3. Check it

curl -s -D - -H 'Accept: text/markdown' https://shop.example/blog/my-first-post

The headers include content-type: text/markdown; charset=utf-8 and the body is the page as Markdown.

What the page needs

  • The controller returns a page result (Magento\Framework\View\Result\Page) and the response status is 200.
  • The layout is cacheable: no block on the page is declared with cacheable="false". This is the privacy boundary. A page Magento would not share between visitors is never served as Markdown, whichever module declares it.
  • The content sits inside the page's <main> element, which is where Magento's page layouts put the content container. A page without a <main> element is converted as a whole.

Cache tags for your page

Your page needs nothing extra for Markdown: its Markdown is kept under the same cache tags as its HTML (see Cache tags and cleaning). As for any cacheable page, that means each block that shows an entity declares it as an identity:

use Magento\Framework\DataObject\IdentityInterface;
use Magento\Framework\View\Element\Template;

class Post extends Template implements IdentityInterface
{
    /**
     * @return string[]
     */
    public function getIdentities(): array
    {
        return [\Vendor\Blog\Model\Post::CACHE_TAG . '_' . $this->getPost()->getId()];
    }
}

A block that shows an entity without declaring it leaves the page as cached, in both formats, until the cache entry expires.

No hard dependency

etc/markdown_content.xml is only read when this module is installed and enabled. Your module can ship the file without requiring qoliber/markdown-content; list the package under suggest in your composer.json instead.

Changing another module's declaration

Declarations with the same id are merged, attribute by attribute, in the order the modules load. To withdraw or relabel a page that another module declared, declare the same id and add that module to the <sequence> of your module.xml:

<page id="blog_post_view" disabled="true"/>

When the page stays HTML

Check Where
The module is enabled for the store view Stores → Configuration → Qoliber → Markdown Content
The page type is not selected under Excluded Page Types the same screen
The id is the full action name compare it with the layout handle file name
The caches were cleaned after the file was added bin/magento cache:clean config full_page
No block on the page has cacheable="false" the page's layout files
The controller returns a page result, not a raw, JSON or forward result the controller
The page is under the size limit and has convertible content var/log/debug.log, when debug logging is on; conversion errors are in var/log/system.log
The Accept header does not prefer HTML Which requests get Markdown
Varnish did not answer from its cache Caching and deployment

Extending

Everything below is etc/di.xml configuration in your own module. Add Qoliber_MarkdownContent to the <sequence> of your module.xml, so that your values are applied after the module's own.

To Do this
Remove more elements for every store Add an XPath expression, relative to the converted element, to the xpaths argument of Model\Conversion\Processor\RemoveNodes. Set an existing item to an empty value to switch it off.
Keep content a theme sends hidden and shows with JavaScript Add an XPath expression for the element to the shownByScript argument of the same class. Hidden elements are removed otherwise.
Recognise another main content element Add an expression to the mainContentXpaths argument of Model\Conversion\ContentSelector.
Turn a theme's section titles into headings Add an item (xpath, level) to the headings argument of Model\Conversion\Processor\PromoteHeadings.
Write out a label a theme prints with CSS Add an item (xpath, attribute) to the labelled argument of Model\Conversion\Processor\RevealLabels.
Change the content before conversion Implement Api\DomProcessorInterface and add it, with a sortOrder, to the processors argument of Service\PageConverter.
Use another conversion library Add a preference for Api\HtmlToMarkdownInterface.
Count tokens exactly Add a preference for Api\TokenEstimatorInterface.

After a change, run bin/magento setup:upgrade (or setup:di:compile in production) and clean the Markdown Content cache: stored Markdown was made with the old rules.

Extending templates

To Do this
Give templates data of your own ({brand.name}) Implement DataResolver\ResolverInterface and add it to the resolvers argument of DataResolver\ResolverPool under its prefix. Return plain arrays and values only, read only the fields asked for, and add the cache tags of what you read to the IdentityCollector.
Add a template function (@stock_message()) Implement Api\TemplateFunctionInterface and add it to the functions argument of Model\Template\FunctionPool. Add the cache tags of what it reads with addCacheTags() of the render context.
Add data without a class of its own Observe qoliber_markdown_content_template_data: change the variables of the event's transport; the event also carries the render context.
Make your own page from templates Give its declaration in etc/markdown_content.xml an entity (e.g. blog_post), a context class implementing Api\PageContextInterface that returns the ID of the entity while the page renders, and a default template (Vendor_Module::markdown/post.tsuku). Add qoliber_markdown_content/templates/<page id>_source and _template fields to your own system.xml to let merchants choose per store view.
Give your entity the AI Markdown tab Add it to the types argument of Model\EntityTemplate\EntityTypes (class, pageType, storeScoped), copy the qoliber_markdown fieldset of view/adminhtml/ui_component/cms_page_form.xml into your form, and plug Model\EntityTemplate\Form::addData() and adjustMeta() into your form's data provider. Saving needs your entity's <prefix>_save_after event observed by Observer\Adminhtml\SaveEntityTemplate.
Use another template engine Add a preference for Api\TemplateEngineInterface. Keep templates away from objects: they are written in the admin.

The resolvers in DataResolver/ use nothing else of this module, so they can move to a package of their own.

The conversion steps

The page is loaded into a DOM, its main content is selected, and these processors run on it in sortOrder before the HTML that is left is converted:

Order Processor What it does
10 remove_nodes Removes scripts, styles, form controls, hidden elements, the theme noise listed in etc/di.xml, and the merchant's selectors. Luma's main menu, which is sent hidden and shown by a script, is kept.
20 normalize_images Resolves lazy-loaded images, drops inline data images and duplicates of the same picture.
30 normalize_links Makes links absolute and reduces links that lead nowhere to their text.
33 reveal_labels Writes out labels a theme keeps in an attribute and prints with CSS, such as "Incl. Tax".
35 promote_headings Turns elements a theme styles as section titles into headings.
40 normalize_blocks Reduces layout elements (section, header, figure, definition lists and others) to plain blocks.
60 separate_inline_from_blocks Keeps text that sits next to a block from running into it.
70 flatten_list_items Keeps each list item, such as a product card, in one item.

Choose a sortOrder between two of these to run your own processor at that point.

Example: remove an element for every store

<type name="Qoliber\MarkdownContent\Model\Conversion\Processor\RemoveNodes">
    <arguments>
        <argument name="xpaths" xsi:type="array">
            <item name="vendor_size_chart" xsi:type="string">.//*[@id="size-chart"]</item>
        </argument>
    </arguments>
</type>

Example: a section title that is not a heading

<type name="Qoliber\MarkdownContent\Model\Conversion\Processor\PromoteHeadings">
    <arguments>
        <argument name="headings" xsi:type="array">
            <item name="vendor_faq_question" xsi:type="array">
                <item name="xpath" xsi:type="string">.//div[contains(concat(" ", normalize-space(@class), " "), " faq-question ")]</item>
                <item name="level" xsi:type="number">3</item>
            </item>
        </argument>
    </arguments>
</type>

Example: your own processor

namespace Vendor\Module\Model\Markdown;

use Qoliber\MarkdownContent\Api\DomProcessorInterface;

class DropUnavailableProducts implements DomProcessorInterface
{
    /**
     * Leave products that cannot be bought out of product lists.
     */
    public function process(\DOMElement $root, string $pageUrl): void
    {
        $document = $root->ownerDocument;
        if ($document === null) {
            return;
        }

        $unavailable = (new \DOMXPath($document))->query(
            './/li[contains(concat(" ", normalize-space(@class), " "), " product-item ")]'
            . '[.//*[contains(concat(" ", normalize-space(@class), " "), " unavailable ")]]',
            $root
        );
        foreach ($unavailable === false ? [] : iterator_to_array($unavailable) as $item) {
            $item->parentNode?->removeChild($item);
        }
    }
}
<type name="Qoliber\MarkdownContent\Service\PageConverter">
    <arguments>
        <argument name="processors" xsi:type="array">
            <item name="vendor_drop_unavailable_products" xsi:type="array">
                <item name="processor" xsi:type="object">Vendor\Module\Model\Markdown\DropUnavailableProducts</item>
                <item name="sortOrder" xsi:type="number">15</item>
            </item>
        </argument>
    </arguments>
</type>

Testing

Suite Proves Needs
Unit (Test/Unit) The Accept rules, the delivery decisions, cache keys and tags, each conversion rule, the reference pages for Luma and Hyvä markup, the markdown_content.xml schema PHP only
Integration (Test/Integration) The wiring in a real Magento: every page type in both request orders, cache tags for saved products, categories and CMS pages, cache cleans, tax display, store views, customer groups and currencies, signed-in customers, Varnish mode at the origin Magento's integration framework with its own database
Playwright (Test/Playwright) The same behaviour over real HTTP against a running store, each setting's effect, and the admin screen. Its marked tests feed the documentation A running store, Node.js
Varnish (Test/Varnish/run.sh) The Playwright Varnish specs against a real Varnish with Magento's VCL and the Markdown rule Docker, and the Playwright suite
HTTP script (Test/Http/acceptance.sh) A quick check with curl only, including headers a browser library refuses to send A running store
Compatibility (Test/Compat/run.sh) The unit tests against another instance's Magento framework, the HTTP script, the Playwright suite and optionally the Varnish specs against its store, for each Magento version the module supports That instance

Unit tests, from the module directory:

../../vendor/bin/phpunit

Integration tests, from the Magento root. The framework installs into the database named in dev/tests/integration/etc/install-config-mysql.php, which must never be the store's own:

cd dev/tests/integration
../../../vendor/bin/phpunit ../../../vendor/qoliber/markdown-content/Test/Integration

Run one integration run at a time, and delete dev/tests/integration/tmp/sandbox-* after the module's plugins or XML changed. While a run is in progress the framework copies Magento's own test modules into app/code of the instance, so do not use the storefront, run the other suites or run setup:upgrade until it has finished.

Playwright, from Test/Playwright. Most specs send plain HTTP requests, the way an agent does, and use no browser:

npm ci && npx playwright install chromium
npx playwright test                                         # agent, shopper, cache and settings specs
ADMIN_USER=... ADMIN_PASS=... npx playwright test           # adds the admin screen specs
SECOND_STORE_BASE_URL=https://de.shop.test/ npx playwright test   # adds the store view specs
Variable Purpose
LUMA_BASE_URL The store under test (default https://markdown-content.test/).
HYVA_BASE_URL A store view that serves a Hyvä theme; runs the same specs there.
PRODUCT_PATH, CATEGORY_PATH, CMS_PATH, SEARCH_PATH The pages to request; the defaults are Mage-OS sample data pages. In a store without sample data, fixtures/magento.php seed-catalog creates a category, three products and a CMS page and prints their paths.
ADMIN_USER, ADMIN_PASS Add the admin specs. Magento's two-factor modules must be off on the test store.
SECOND_STORE_BASE_URL, SECOND_STORE_CODE A second store view on its own address, with another locale. Create it once with fixtures/magento.php store-view and map the address in the web server.

The cache specs prove where a response came from with the HIT and MISS headers Magento and this module send in developer mode. In any other mode they still check that every visitor gets the right format.

Varnish, from the module directory. The script starts a Varnish of its own in Docker in front of the instance, switches the instance to Varnish for the length of the run, and puts everything back when it ends:

Test/Varnish/run.sh /path/to/magento

Another Magento version, from the module directory. The script installs this checkout into the instance, creates a small test catalog there (a category, three products, one with a picture, a CMS page with structured data, and a tax rule where nothing taxes the test destination), runs the unit tests against that instance's framework when it has PHPUnit 10 or later, and the other suites against its default and second store views (--hyva adds a store view with a Hyvä theme). An instance in default mode runs in developer mode meanwhile, so that the cache checks can see where a page came from, unless developer mode breaks its storefront: Magento 2.4.6 and 2.4.7 reject their own search configuration schema under libxml 2.12 or later, and there the run stays in default mode. Afterwards it puts the instance back, and it lists every test that was skipped, with the reason. It refuses an instance that other tests are running against, because the two would fail each other:

Test/Compat/run.sh /path/to/another/magento --varnish

The HTTP script:

Test/Http/acceptance.sh https://shop.test /product.html /category.html /cms-page /path/to/magento

The Magento root is optional. With it, the script cleans the page cache between scenarios and, when the built-in page cache is on, runs the cache tag scenario.

The Playwright suite, the Varnish script and the HTTP script change settings and save a product, a category and a CMS page under another name for a moment. They read the value first, put it back, and fail loudly if they cannot. Run them against a development or staging store, never production.

Troubleshooting

Symptom Cause and fix
Every page stays HTML The module is off for the store view, or the pages were cached before it was switched on: refresh the Page Cache.
One page stays HTML See When the page stays HTML.
GET returns Markdown but HEAD answers as HTML Generated code is older than the module: run bin/magento setup:upgrade, and setup:di:compile in production.
A fatal error that names a Proxy or Interceptor class of this module after an update The same cause and fix.
Agents get HTML behind Varnish or a CDN The cache answered before Magento was asked: add the bypass rule.
Markdown requests are slower than HTML requests for the same cached page The Markdown Content cache type is switched off: bin/magento cache:enable qoliber_markdown_content.
A changed product or page still shows its old content as Markdown Its HTML is stale too: a block on the page does not declare the entity as an identity. See Cache tags for your page.
A price display or tax setting changed but pages still show the old prices, in both formats Magento itself keeps the old display until its cache is flushed: bin/magento cache:flush.
A signed-in test session gets HTML That is the default. Turn on Serve Signed-in Customers if the store should serve them.
The Markdown lacks content that is visible in the browser The theme renders it with JavaScript; see Limitations.
The Markdown contains something it should not Add its selector under Additional Elements to Remove, or a rule for every store as shown under Extending.

Limitations

  • Content a theme renders with JavaScript after the page loads (configurable product options, gallery images beyond the first in Luma) is not in the HTML and therefore not in the Markdown.
  • Behind Varnish or a CDN, Markdown needs the bypass rule, and the first Markdown request for a page renders it; later ones are answered from the kept Markdown.
  • The token count is an estimate (bytes ÷ 4), not the count of any particular model.
  • With "Whole document" on a Hyvä theme, the Markdown also holds what Hyvä keeps in the page for its mobile menu and its sign-in dialog, so the menu appears twice. "Main content only", the default, is not affected.
  • Price labels with and without tax are written out for Luma markup.
  • Behind Varnish with the "Whole document" setting, the navigation menu is missing from the Markdown: Varnish assembles that block itself, and Magento's page does not contain it.

Contributing

Issues and pull requests are welcome at github.com/qoliber/markdown-content. See CONTRIBUTING.md; AGENTS.md has the same guidance for AI coding agents.

Security

Report vulnerabilities privately as described in SECURITY.md, never in a public issue.

License

MIT © Qoliber. Commercial support and custom work: qoliber.com.