Repository navigation
feat(documents): htmlToMarkdown and markdownToHtml for blog bodies - #3112
Merged
Merged
Conversation
A blog keeps HTML (WordPress, Ghost) and a CLI shows and takes Markdown. Both directions treat the body as untrusted: raw HTML (including WordPress block and Ghost card comments), scripts, styles, frames and event attributes go, and links and images with a scheme other than http(s), mailto or tel keep only their text. A reference whose first definition is unsafe stays unlinked. Tested on one post as WordPress 6.9.4 stores and renders it and as Ghost 6.78.0 renders it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task
Give content CLIs (WordPress, Ghost) one way to turn a post body from HTML into Markdown and back.
Why
A blog keeps HTML; a CLI shows and takes Markdown. Each content CLI writing its own converter would repeat the same untrusted-input rules, so they live in
@wirecat/cli-core/documents.What
htmlToMarkdownandmarkdownToHtml, built on unified'shast-util-from-html,hast-util-to-mdast,mdast-util-to-hastandhast-util-to-html, loaded on first use.docs/dev/DOCUMENTS.mddescribes both and notes the risk of writing a converted body back (what the conversion drops is lost on save).Testing
test/fixtures/posts/); Markdown that went through HTML once comes back the same.🤖 Generated with Claude Code