Automatically serve your WordPress content as Markdown when requested via the
Accept: text/markdownHTTP header.
This WordPress plugin uses Domscribe PHP to convert your WordPress pages and posts to semantic Markdown on-the-fly, making your content accessible to Markdown-based applications, AI assistants, and content aggregators.
- Automatic Markdown Conversion: Serves Markdown when
Accept: text/markdownheader is present - Smart Content Extraction: Automatically detects and extracts main content
- Performance Optimized: Built-in caching system for fast responses
- Highly Configurable: Full control via WordPress admin panel
- SEO-Friendly Metadata: Includes post metadata in YAML frontmatter
- Post Type Filtering: Choose which post types to convert
- URL Management: Option to convert URLs to relative paths or reference-style links
- Developer Friendly: Hooks and filters for customization
This plugin includes all dependencies bundled in the lib/ directory. No need for Composer!
-
Download the plugin:
- Download the zip file from releases
- Or clone:
git clone https://github.com/acseo/domscribe-wordpress.git
-
Install:
- Upload to
wp-content/plugins/domscribe-wordpress - Or extract zip file in plugins directory
- Upload to
-
Activate:
- Go to WordPress Admin β Plugins
- Find "Domscribe WordPress" and click "Activate"
That's it! The plugin is ready to use.
For developers who want to use Composer for development tools:
cd wp-content/plugins/domscribe-wordpress
composer install --devThis installs PHPStan and CodeSniffer for code quality checks, but is not required for the plugin to work.
Go to Settings β Domscribe in your WordPress admin panel.
| Option | Description | Default |
|---|---|---|
| Enable Markdown Conversion | Master switch for the plugin | On |
| Extract Main Content | Automatically detect and extract main content | On |
| Reference-style Links | Convert inline links to reference format | Off |
| Strip Site URL | Convert absolute URLs to relative paths | On |
| Enable Caching | Cache converted Markdown for performance | On |
| Cache Duration | How long to cache results (seconds) | 3600 |
| Allowed Post Types | Which post types to convert | Posts, Pages |
Once activated, any request with the Accept: text/markdown header will receive Markdown:
curl -H "Accept: text/markdown" https://your-site.com/sample-post/---
title: Sample Post Title
author: John Doe
date: 2026-03-09T10:00:00+00:00
url: https://your-site.com/sample-post/
categories: [Technology, Tutorial]
tags: [WordPress, Markdown]
---
# Sample Post Title
This is the main content of your post, automatically converted to Markdown.
## Features
- Automatic conversion
- Smart content extraction
- SEO-friendly output
[Read more](https://example.com)# Get a specific post as Markdown
curl -H "Accept: text/markdown" https://your-site.com/hello-world/
# Save to file
curl -H "Accept: text/markdown" https://your-site.com/hello-world/ > post.md
# Get homepage
curl -H "Accept: text/markdown" https://your-site.com/http https://your-site.com/sample-post/ Accept:text/markdownUse browser developer tools to modify the Accept header:
- Open DevTools (F12)
- Go to Network tab
- Right-click on a request β Edit and Resend
- Modify
Acceptheader totext/markdown - Send the request
add_filter('domscribe_wp_conversion_options', function($options) {
// Customize Domscribe conversion options
$options['refify_urls'] = true;
$options['custom_option'] = 'value';
return $options;
});add_filter('domscribe_wp_markdown_output', function($markdown, $html) {
// Modify the final Markdown output
$markdown = "<!-- Custom header -->\n\n" . $markdown;
return $markdown;
}, 10, 2);add_action('domscribe_wp_before_conversion', function($post_id) {
// Do something before HTML is converted
error_log("Converting post {$post_id} to Markdown");
});Allow AI assistants to easily consume your content in Markdown format:
import requests
response = requests.get(
'https://your-site.com/article/',
headers={'Accept': 'text/markdown'}
)
markdown_content = response.text
# Process with your AI/LLMBuild content aggregators that prefer Markdown:
fetch('https://your-site.com/post/', {
headers: {
'Accept': 'text/markdown'
}
})
.then(response => response.text())
.then(markdown => {
// Process markdown
});Export WordPress documentation to Markdown files:
#!/bin/bash
posts=(
"getting-started"
"api-reference"
"troubleshooting"
)
for post in "${posts[@]}"; do
curl -H "Accept: text/markdown" \
"https://docs.example.com/$post/" \
> "docs/$post.md"
doneUse WordPress as a CMS and export to static Markdown:
<?php
// Export all posts to Markdown files
$posts = get_posts(['numberposts' => -1]);
foreach ($posts as $post) {
$url = get_permalink($post);
$markdown = file_get_contents($url, false, stream_context_create([
'http' => [
'header' => 'Accept: text/markdown'
]
]));
file_put_contents(
"export/{$post->post_name}.md",
$markdown
);
}// In your theme's functions.php
add_filter('domscribe_wp_allowed_post_types', function($post_types) {
$post_types[] = 'product';
$post_types[] = 'portfolio';
return $post_types;
});add_filter('domscribe_wp_post_metadata', function($metadata, $post) {
$metadata['custom_field'] = get_post_meta($post->ID, 'custom_field', true);
$metadata['reading_time'] = calculate_reading_time($post);
return $metadata;
}, 10, 2);The plugin includes several performance optimizations:
- Smart Caching: Results are cached with automatic invalidation
- Conditional Processing: Only processes requests with appropriate headers
- Minimal Overhead: Zero impact on normal WordPress requests
- Efficient Conversion: Uses optimized Domscribe PHP library
Normal HTML request: ~100ms
First Markdown request: ~150ms (conversion)
Cached Markdown request: ~105ms (minimal overhead)
- Check plugin is activated
- Verify "Enable Markdown Conversion" is checked in settings
- Ensure post type is in allowed list
- Confirm
Accept: text/markdownheader is being sent
Clear cache in Settings β Domscribe β Cache Management
The plugin should work out of the box. If you see any errors:
- Verify the
lib/directory exists and contains files - Check PHP version (must be 8.0+)
- Check file permissions
- PHP 8.0 or higher
- WordPress 5.8 or higher
- Composer (for dependency management)
Contributions are welcome! Please see CONTRIBUTING.md for details.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Domscribe PHP
- Developed by ACSEO
For support and questions: