Automattic / Automattic/php-toolkit
Feature: Add Classic Editor & Standard HTML Support for Post Import/Export (PushMd)
- Vorherrschende Sprache
- PHP
- Sterne
- 22
- Forks
- 5
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
## Overview
Currently, Push MD assumes all WordPress posts use the Gutenberg Block Editor and wraps content in block comments (e.g., ``). On sites or post types where the Classic Editor is active (or where Gutenberg is disabled), importing Markdown yields block-comment markup in plain HTML editors, while exporting classic HTML posts is broken and even simple headings and lists do not convert to clean Markdown.
I understand Gutenberg is much cleaner to implement and HTML can be messy. But a lot of people still use Classic Editor or hand coded HTML.
We should support Classic Editor and non-block post types natively during both import (Markdown → HTML) and export (HTML → Markdown).
Note: I've already implemented this and will be sending a PR soon. Creating this issue for reference.
---
## Technical Plan
### 1. Editor Detection Strategy
- Introduce a helper method `is_block_editor_enabled( $post_type )` in `Push_MD_Plugin`:
- Check WordPress core's `use_block_editor_for_post_type( $post_type )` when available.
- Fall back to checking if `register_block_type` exists.
- Provide a filter `push_md_use_block_editor` allowing developers to override the decision per post type.
### 2. Markdown Consumer Wrapper (`Push_MD_Markdown_Consumer`)
- Wrap `WordPress\Markdown\MarkdownConsumer` to handle classic editor post targets _(because we may not want to modify the vendor components)_:
- When block editor is **enabled** for the target post type: delegate directly to `MarkdownConsumer` to return Gutenberg block markup.
- When block editor is **disabled** for the target post type:
- Consume Markdown via `MarkdownConsumer`.
- Strip Gutenberg block comment wrappers (e.g., `` and ``).
- Remove block-specific CSS classes (`wp-block-*`).
- Normalize excess blank lines to output clean standard HTML suitable for the Classic Editor.
### 3. Markdown Producer Wrapper (`Push_MD_Markdown_Producer`)
- Wrap `WordPress\Markdown\MarkdownProducer` to handle posts without block markup _(because we may not want to modify the vendor components)_:
- Detect whether content contains Gutenberg blocks (`has_blocks( $content )` or fallback delimiter check `
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne mit Push_MD_Plugin und verfolge die Import-/Export-Pfade durch Push_MD_Markdown_Consumer und Push_MD_Markdown_Producer. Überprüfe die genannten WordPress-APIs zur Erkennung des Editors und die Anforderungen an Push_MD_HTML_Converter. Als abgeschlossen gilt, dass Beiträge im Block-Editor das Gutenberg-Verhalten beibehalten, während Classic Editor- und Standard-HTML-Beiträge in beide Richtungen sauber konvertiert werden, einschließlich Metadaten und Formatierung.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php, wordpress
- Bereich
- backend, content
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100