@unifast/core
v0.0.5
Published
TypeScript type definitions for unifast
Maintainers
Readme
@unifast/core
Shared TypeScript type definitions and HAST utilities for unifast — a high-performance Markdown/MDX compiler with a Rust core.
Install
npm install @unifast/coreNote: This package is a dependency of
@unifast/node. You typically don't need to install it directly unless you're building a custom integration.
API
Types
CompileOptions— Configuration object for the compiler (input kind, output kind, plugin options)CompileResult— Result of compilation (output, frontmatter, diagnostics, stats, toc, readingTime, excerpt)UnifastPlugin— Plugin interface withname,options,hastTransform, andmdxJsTransformTocEntry— Table of contents entry (depth,text,slug)SanitizeSchema— HTML sanitization configuration
HAST Types
HastRoot,HastElement,HastText,HastRaw,HastComment,HastDoctype
Utilities
hastToHtml(hast)— Convert a HAST tree to an HTML stringescapeHtml(str)— Escape HTML special charactersextractLang(node)— Extract the language from a code block nodeextractText(node)— Extract text content from a HAST nodefindCodeChild(node)— Find the<code>child inside a<pre>nodevisitHast(tree, visitor)— Walk a HAST tree
Built-in Plugins
All 30+ built-in plugins are exported as factory functions (e.g., gfm(), frontmatter(), syntect(), toc(), etc.). See the main README for the full list.
Error Classes
UnifastError,ParseError,CompileError
