Automattic / Automattic/php-toolkit
Feature: Add Classic Editor & Standard HTML Support for Post Import/Export (PushMd)
- Lenguaje dominante
- PHP
- Estrellas
- 22
- Forks
- 5
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
## 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 `
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comienza con Push_MD_Plugin y sigue las rutas de importación/exportación a través de Push_MD_Markdown_Consumer y Push_MD_Markdown_Producer. Revisa las APIs de WordPress mencionadas para la detección del editor y los requisitos de Push_MD_HTML_Converter. Se considera terminado cuando las entradas del editor de bloques conservan el comportamiento de Gutenberg, mientras que las entradas de Classic Editor y de HTML estándar se convierten correctamente en ambas direcciones, incluidos los metadatos y el formato.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- php, wordpress
- Área
- backend, content
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 25/100