Package WordPress HTML-to-Markdown and add a self-contained Markdown-to-HTML parser
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
阅读 MarkdownConsumer 和 MarkdownProducer,包括私有的 DataLiberationHTMLProcessor token walk,然后运行现有的 dmsnell/html-to-md standalone test suite。完成的标准是:无需 League dependency graph 即可提供直接的 Markdown-to-HTML 和 HTML-to-Markdown APIs,并具备指定的 fixtures、corpus、differential、fuzz、performance 以及 standalone-runtime coverage。
由索引模型根据 Issue 内容生成。
描述
Goal
Provide a generic, self-contained Markdown <-> HTML codec in PHP Toolkit by packaging the existing WordPress HTML API renderer for HTML-to-Markdown and implementing the missing PHP Markdown-to-HTML direction without embedding the current CommonMark vendor graph.
Existing Upstream
dmsnell/html-to-md is the existing WordPress-oriented HTML-to-Markdown implementation. It uses the WordPress HTML API, has no production Composer dependencies, supports standalone execution through bundled HTML API dependencies, and is already the selected conversion layer for WordPress/ai#845.
PHP Toolkit should coordinate with and package that renderer rather than create a competing HTML-to-Markdown serializer. Adoption should follow the correctness work in dmsnell/html-to-md#17 and differential validation against the toolkit and downstream corpora.
No corresponding self-contained PHP Markdown-to-HTML parser was found in that project, Dennis Snell's other public repositories, or WordPress core. That missing parser remains the primary implementation work for this issue.
Context
The Markdown component already owns practical Markdown <-> WordPress block conversion. MarkdownConsumer currently parses with league/commonmark, while MarkdownProducer contains a private HTML-to-Markdown token walk built on DataLiberationHTMLProcessor. MarkdownConsumer also records the architectural direction directly: a dedicated parser would improve complexity, bundle size, performance, and PHP compatibility.
A reusable HTML boundary is needed by consumers whose canonical composition is:
Markdown <-> HTML <-> WordPress blocks
Automattic/blocks-engine#1189 tracks removing Blocks Engine's duplicate League dependency graph. Automattic/blocks-engine#1523 established direct HTML interchange so it can consume an upstream codec without changing product contracts.
Proposed Surface
Provide small public primitives equivalent to:
$html = MarkdownToHtmlConverter::convert( $markdown, $options );
$markdown = HtmlToMarkdownConverter::convert( $html, $options );
The exact names should follow toolkit conventions. The important contract is direct Markdown <-> HTML conversion independent of WordPress block serialization. MarkdownConsumer and MarkdownProducer can compose those primitives for their existing block-facing APIs.
The HTML-to-Markdown primitive should package or adapt dmsnell/html-to-md. The Markdown-to-HTML primitive should be a bounded, self-contained PHP parser owned through the toolkit or a coordinated WordPress package.
Acceptance Criteria
- The Markdown component exposes direct Markdown-to-HTML and HTML-to-Markdown APIs.
- The direct APIs do not require a WordPress block round trip.
- HTML-to-Markdown reuses or directly coordinates with
dmsnell/html-to-mdrather than duplicating its renderer. - The adopted renderer includes the list, table, code-fence, and invisible-marker correctness fixes tracked in
dmsnell/html-to-md#17or equivalent upstream fixes. - The renderer has a stable package, autoload, versioning, and standalone-runtime contract suitable for PHP Toolkit consumers.
- Markdown-to-HTML uses a self-contained PHP parser without
league/commonmarkor its transitive vendor graph. - Markdown-to-block and block-to-Markdown behavior composes through the shared HTML codec where appropriate.
- The existing private producer conversion is retired or reduced to a compatibility adapter over the shared renderer.
- Headings, paragraphs, emphasis, links, images, lists, blockquotes, code fences, thematic breaks, tables, raw HTML islands, and frontmatter boundaries have deterministic fixtures.
- Parsing and serialization have explicit input, nesting, definition, and output budgets with fail-closed diagnostics for malformed or adversarial input.
- Existing source-aware editing and opaque preservation behavior remain covered.
- Corpus, differential, fuzz, and performance tests establish behavior before embedded dependencies are removed.
- The component remains usable outside WordPress and in constrained PHP/Playground deployments.
Downstream Adoption
Once released, Blocks Engine can replace its League-backed MarkdownAdapter internals with the toolkit codec while preserving its optional adapter and result-envelope contracts. Static-site and Markdown-first WordPress products then share the maintained WordPress-oriented conversion primitives.
AI assistance disclosure: OpenAI gpt-5.6-sol via OpenCode inspected dmsnell/html-to-md, dmsnell/blocky-formats, WordPress core, PHP Toolkit, Blocks Engine, the public WordPress/AI integration tracker, and downstream conversion fixtures; ran the renderer's standalone test suite; and refined this issue's ownership and acceptance criteria. Chris Huber directed the scope and remains responsible for review.
- 主要语言
- PHP
- 星标
- 61
- 派生
- 23
- 平均合并
- 20 小时 9 分钟
- 30 天内合并 PR
- 7
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
WordPress/php-toolkit 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 58/100
WordPress/php-toolkit#306 ·
维护者通常 1 天内回复
-
WPCS compliance未关闭
难度 4/5 3-5 天 新手友好度 35/100
WordPress/php-toolkit#157 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
WordPress/php-toolkit#138 · 7 条评论 · 2 个 reaction ·
维护者通常 1 天内回复
-
[Blueprints v2] Constraint the Blueprint bundle format可能已有人在做 @JanJakes 于 436 天前认领。 未关闭Blueprints enhancement
WordPress/php-toolkit#132 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
WordPress/php-toolkit#129 ·
维护者通常 1 天内回复
查看 WordPress/php-toolkit 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
crazy-goat/rabbit-stream#753 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
opensourcepos/opensourcepos#4743 ·
维护者通常 2 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
grokability/snipe-it#19786 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 69/100
PrestaShop/PrestaShop#43140 ·
维护者通常 1 天内回复