From sanity
Converts HTML and Markdown to Portable Text blocks for Sanity using @portabletext/markdown and @portabletext/block-tools. For content migration, imports, pipelines, and manual construction.
npx claudepluginhub anthropics/claude-plugins-official --plugin sanityThis skill uses the workspace's default tool permissions.
Convert external content (HTML, Markdown) into Portable Text for Sanity. Three main approaches:
Renders and serializes Portable Text to React, Svelte, Vue, Astro, HTML, Markdown, and plain text. Use for frontend rendering, custom serializers, server-side conversions, text extraction, and troubleshooting blocks, marks, lists.
Imports PDF, DOCX, PPTX, XLSX, HTML documents into clean, editable markdown for project documentation, content rewriting, or remediation.
Converts PDFs, DOCX, PPTX, XLSX, HTML, images, URLs, CSV, JSON, and more to markdown via tiered fallbacks: MCP markitdown, native tools, or user notice. For ingesting non-plain-text files.
Share bugs, ideas, or general feedback.
Convert external content (HTML, Markdown) into Portable Text for Sanity. Three main approaches:
markdownToPortableText — Convert Markdown directly using @portabletext/markdown (recommended for Markdown)htmlToBlocks — Parse HTML into PT blocks using @portabletext/block-tools (for HTML migration)Understand the target format before converting. PT is an array of blocks:
[
{
"_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 rules:
_key (unique within the array)_type: "block" is for text blocks; custom types use their own _typemarkDefs holds annotation data; marks on spans reference markDefs[*]._key or are decorator stringslistItem ("bullet" | "number") and level (1, 2, 3...) on regular blocksRead the rule file matching your source format:
rules/markdown-to-pt.md — @portabletext/markdown with markdownToPortableText (recommended)rules/html-to-pt.md — @portabletext/block-tools with htmlToBlocksrules/manual-construction.md — build blocks programmatically from any sourceNote:
@sanity/block-toolsis the legacy package name. Always use@portabletext/block-toolsfor new projects. The API is the same.