Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Feature: Add Classic Editor & Standard HTML Support for Post Import/Export (PushMd)

Đang mở
#91 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
php, wordpress
Lĩnh vực
backend, content

Hướng nghiên cứu

Bắt đầu với Push_MD_Plugin và lần theo các đường dẫn nhập/xuất qua Push_MD_Markdown_Consumer và Push_MD_Markdown_Producer. Xem xét các API WordPress được nêu để phát hiện trình soạn thảo và các yêu cầu của Push_MD_HTML_Converter. Được coi là hoàn thành khi các bài viết trong trình soạn thảo khối vẫn giữ nguyên hành vi của Gutenberg, trong khi các bài viết của Classic Editor và HTML tiêu chuẩn được chuyển đổi chính xác theo cả hai chiều, bao gồm siêu dữ liệu và định dạng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Overview

Currently, Push MD assumes all WordPress posts use the Gutenberg Block Editor and wraps content in block comments (e.g., <!-- wp:paragraph -->). 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., <!-- wp:... --> and <!-- /wp:... -->).
      • 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 <!-- wp:).
    • Gutenberg content: Delegate to MarkdownProducer and normalize the output Markdown.
    • Classic/Standard HTML content: Extract post metadata into YAML frontmatter and convert standard HTML into clean Markdown.
4. HTML to Markdown Converter (Push_MD_HTML_Converter)
  • Provide bidirectional conversion and normalization utilities for HTML/Markdown:
    • Convert standard HTML tags (headings, paragraphs, lists, links, blockquotes, inline formatting) into idiomatic Markdown.
    • Handle list items, line breaks, and paragraph spacing cleanly without redundant blank lines.
    • Provide normalization routines for produced Markdown output - for common quirks like extra spaces, non-breaking spaces etc.
Ngôn ngữ chính
PHP
Star
22
Fork
5
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Automattic/php-toolkit

Tất cả issue của Automattic/php-toolkit

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.