@xmdx/napi
v0.0.8
Published
High-performance streaming Markdown to HTML parser built with Rust for Astro (Node.js NAPI bindings)
Maintainers
Readme
@xmdx/napi
Native Node.js bindings for xmdx - a high-performance Markdown/MDX compiler built with Rust.
Supported Platforms
| Platform | Architecture | Package |
|----------|--------------|---------|
| macOS | x64 | @xmdx/napi-darwin-x64 |
| macOS | ARM64 | @xmdx/napi-darwin-arm64 |
| Windows | x64 | @xmdx/napi-win32-x64-msvc |
| Linux (glibc) | x64 | @xmdx/napi-linux-x64-gnu |
| Linux (glibc) | ARM64 | @xmdx/napi-linux-arm64-gnu |
| Linux (musl) | x64 | @xmdx/napi-linux-x64-musl |
| Linux (musl) | ARM64 | @xmdx/napi-linux-arm64-musl |
The correct binary is automatically selected at install time.
Installation
npm install @xmdx/napiAPI
compile(source: string): string
Compiles Markdown source to HTML synchronously.
import { compile } from '@xmdx/napi';
const html = compile('# Hello, world!');
console.log(html);
// <h1>Hello, world!</h1>compileCodeBlock(code: string, lang: string): Promise<string>
Compiles a code block with syntax highlighting using Shiki.
import { compileCodeBlock } from '@xmdx/napi';
const html = await compileCodeBlock('const x = 1;', 'javascript');Build from Source
# Install dependencies
pnpm install --frozen-lockfile
# Build NAPI binary
pnpm run build
# Run tests
pnpm testDevelopment
# Smoke test against fixture
pnpm run smoke:napi -- ../../fixtures/core/markdown/hello.mdNotes
- The
napiCLI must be available vianode_modules/.bin(comes from devDependencies) - If you see
napi: not found, runpnpm installfirst - Requires Node.js >= 10
License
MIT
