Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"!drizzle",
"!src/store/sqlite/migrations.generated.ts",
"!src/search/snowball",
"!test/fixtures/posts",
"!.worktrees",
"!.claude",
"!config/wirecat",
Expand Down
8 changes: 8 additions & 0 deletions changes/feat-html-markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Added

- **`htmlToMarkdown` and `markdownToHtml` in `@wirecat/cli-core/documents`**, for the content category: a blog keeps
HTML (WordPress, Ghost), and a CLI shows and takes Markdown. WordPress block comments and Ghost card comments go,
and so do scripts, styles, frames, event attributes, raw HTML from Markdown, and links and images whose scheme is
not http(s), mailto or tel: a post body is untrusted. Tested on one post as WordPress 6.9 stores and renders it and
as Ghost 6.78 renders it; Markdown that went through HTML once comes back the same. The converters are unified's
`hast-util-from-html`, `hast-util-to-mdast`, `mdast-util-to-hast` and `hast-util-to-html`, loaded on first use.
8 changes: 8 additions & 0 deletions docs/dev/DOCUMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,14 @@ differ change (a tick is flipped inside its line), so the rest keeps its markers
byte-order mark. The result is parsed again and must read as `next`; otherwise it returns undefined and the caller
reports a conflict instead of writing. `blocksMarkdown` writes blocks as Markdown that reads back as the same blocks.

A service that keeps HTML, such as a blog (WordPress, Ghost), converts with `htmlToMarkdown` and `markdownToHtml`
(async; loaded on first use). Both treat the body as untrusted: comments (WordPress's block comments, Ghost's card
comments), scripts, styles, frames and event attributes go, Markdown's raw HTML is not written, and a link or image
whose scheme is not http(s), mailto or tel keeps only its text. Markdown that went through HTML once comes back the
same; the tests run on real WordPress and Ghost posts in `test/fixtures/posts/`. HTML that went through Markdown does not:
embeds, frames, classes and block comments are lost, so a CLI that reads a post, edits it and writes it back
flattens it. Such a CLI warns or refuses to write back a body that had them.

## Copy a document collection to another database

Use `previewDocumentTransfer` and `applyDocumentTransfer` from `@wirecat/cli-core/store` to retain
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@
"disposable-email-domains-js": "1.26.0",
"echarts": "6.1.0",
"fflate": "0.8.3",
"hast-util-from-html": "2.1.0",
"hast-util-to-html": "9.0.6",
"hast-util-to-mdast": "10.1.3",
"iconv-lite": "0.7.3",
"image-size": "2.0.4",
"linkedom": "0.18.14",
Expand All @@ -285,6 +288,8 @@
"mammoth": "1.13.0",
"mdast-util-from-markdown": "2.1.0",
"mdast-util-gfm": "3.1.0",
"mdast-util-to-hast": "13.2.2",
"mdast-util-to-markdown": "2.2.0",
"micromark-extension-gfm": "3.0.0",
"mpg123-decoder": "1.0.3",
"ogg-opus-decoder": "1.7.5",
Expand Down
Loading
Loading