Loading...
Loading...
Convert HTML and Markdown content into Portable Text blocks for Sanity. Use when migrating content from legacy CMSs, importing HTML or Markdown into Sanity, building content pipelines that ingest external content, converting rich text between formats, or programmatically creating Portable Text documents. Covers @portabletext/markdown (markdownToPortableText), @portabletext/block-tools (htmlToBlocks), custom deserializers, and the Portable Text specification for manual block construction.
npx skill4agent add sanity-io/agent-toolkit portable-text-conversionmarkdownToPortableText@portabletext/markdownhtmlToBlocks@portabletext/block-tools[
{
"_type": "block",
"_key": "abc123",
"style": "normal",
"children": [
{"_type": "span", "_key": "def456", "text": "Hello ", "marks": []},
{"_type": "span", "_key": "ghi789", "text": "world", "marks": ["strong"]}
],
"markDefs": []
},
{
"_type": "block",
"_key": "jkl012",
"style": "h2",
"children": [
{"_type": "span", "_key": "mno345", "text": "A heading", "marks": []}
],
"markDefs": []
},
{
"_type": "image",
"_key": "pqr678",
"asset": {"_type": "reference", "_ref": "image-abc-200x200-png"}
}
]_key_type: "block"_typemarkDefsmarksmarkDefs[*]._keylistItemlevelrules/markdown-to-pt.md@portabletext/markdownmarkdownToPortableTextrules/html-to-pt.md@portabletext/block-toolshtmlToBlocksrules/manual-construction.mdNote:is the legacy package name. Always use@sanity/block-toolsfor new projects. The API is the same.@portabletext/block-tools