https://github.com/bph/wp-markdown-endpoint
Exposes posts and pages as Markdown via .md URL suffix, Accept header negotiation, and auto-discovery links.
https://github.com/bph/wp-markdown-endpoint
markdown plugins wordpress
Last synced: 4 months ago
JSON representation
Exposes posts and pages as Markdown via .md URL suffix, Accept header negotiation, and auto-discovery links.
- Host: GitHub
- URL: https://github.com/bph/wp-markdown-endpoint
- Owner: bph
- Created: 2026-01-16T21:31:01.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-02-23T16:48:16.000Z (4 months ago)
- Last Synced: 2026-02-24T00:31:40.576Z (4 months ago)
- Topics: markdown, plugins, wordpress
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# WP Markdown Endpoint
A WordPress plugin that exposes posts and pages as Markdown via `.md` URL suffix, `Accept` header negotiation, and auto-discovery links.
## Features
- **`.md` URL suffix** — append `.md` to any post or page URL to receive its content as Markdown (e.g. `https://example.com/my-post.md`)
- **`Accept` header negotiation** — send `Accept: text/markdown` to get a Markdown response without changing the URL
- **`?format=md` query parameter** — an alternative way to request Markdown output
- **YAML frontmatter** — every Markdown response includes structured metadata (title, date, author, URL, tags, categories, excerpt)
- **Canonical `Link` header** — Markdown responses include a `Link: <…>; rel="canonical"` HTTP header pointing back to the original HTML page
- **Auto-discovery link** — a `` tag is injected into the HTML `` of every singular post/page so clients can discover the Markdown URL automatically
- **HTML-to-Markdown conversion** — converts Gutenberg block output (headings, paragraphs, lists, blockquotes, code blocks, images, links, bold, italic, strikethrough) to clean Markdown
## Requirements
- WordPress 6.0 or later (uses `str_ends_with()`)
- PHP 8.0 or later
## Installation
1. Upload the `wp-markdown-endpoint` folder to `/wp-content/plugins/`.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. No configuration required.
## Usage
Given a post at `https://example.com/hello-world/`, you can retrieve its Markdown content in three ways:
```
# URL suffix
GET https://example.com/hello-world.md
# Query parameter
GET https://example.com/hello-world/?format=md
# Accept header
GET https://example.com/hello-world/
Accept: text/markdown
```
### Example response
```markdown
---
title: Hello World
date: 2026-02-23
author: Jane Doe
url: https://example.com/hello-world/
tags: ["news", "updates"]
categories: ["General"]
---
## Introduction
Welcome to my site! This content is served as **Markdown**.
```
## File Structure
```
wp-markdown-endpoint/
├── wp-markdown-endpoint.php # Plugin bootstrap, defines constants, loads classes
├── includes/
│ ├── class-rewrite.php # Intercepts .md URL suffix, sets format query var
│ ├── class-output.php # Serves Markdown responses and injects discovery link
│ └── class-converter.php # Converts HTML (Gutenberg output) to Markdown
├── readme.md # This file
└── readme.txt # WordPress.org-compatible readme
```
## License
GPL-2.0+. See [https://www.gnu.org/licenses/gpl-2.0.html](https://www.gnu.org/licenses/gpl-2.0.html).
## Author
Birgit Pauli-Haack