Registry / devops / markdown-it-compiler

markdown-it-compiler

JSON →
library0.1.0jsnpmunverified

A configurable wrapper around markdown-it that simplifies processing Markdown to HTML with presets, options, plugins, and post-processing. Version 0.1.0 (stable) provides a single class-based API for configuring markdown-it, including preset selection, options, plugin arrays, a configure callback for custom plugins, and a format function for post-processing HTML and frontmatter attributes. Unlike raw markdown-it usage, this compiler centralises setup and adds structured output with attributes, TOC, body, and HTML. No recent updates; release cadence is unknown.

npm install markdown-it-compiler
INSTALL
IMPORT
SIG · MARKDOWN-IT-COMPIL
M
markdown-it-compiler
devopsjavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MarkdownItCompiler
import { MarkdownItCompiler } from 'markdown-it-compiler'
import MarkdownItCompiler from 'markdown-it-compiler'
This package uses named exports (TypeScript types included). Default import will fail at runtime.
CompilerConfig
import type { CompilerConfig } from 'markdown-it-compiler'
import { CompilerConfig } from 'markdown-it-compiler'
CompilerConfig is only a type; use import type to avoid runtime errors.
Content
import type { Content } from 'markdown-it-compiler'
const { Content } = require('markdown-it-compiler')
Content is an interface for the format callback parameter. Do not destructure via require.

Shows full usage: import types, create config with options/plugins/configure/format, compile markdown, and access html output.

import { MarkdownItCompiler } from 'markdown-it-compiler'; import type { CompilerConfig } from 'markdown-it-compiler'; const config: CompilerConfig = { options: { linkify: true, html: true, typographer: true }, plugins: [ 'markdown-it-abbr', ['markdown-it-anchor', { permalink: true }] ], configure(md) { // custom plugin md.use((md) => { md.core.ruler.push('custom', (state) => { return true; }); }); }, format(content) { if (content.attributes.layout === 'article') { return `<article>${content.html}</article>`; } return content.html; } }; const compiler = new MarkdownItCompiler(config); const doc = compiler.compile('# Hello'); console.log(doc.html);
Debug
Known issues
breakingNamed export only: default export removed in v0.1.0.
fix
Use `import { MarkdownItCompiler } from 'markdown-it-compiler'`.
affects: >=0.1.0
breakingConstructor argument changed: was `(preset, options, plugins)` tuple, now single config object.
fix
Pass a single object with `preset`, `options`, `plugins`, `configure`, `format` keys.
affects: >=0.1.0
gotchaPlugin names as strings must be resolved by require.resolve; ensure the plugin package is installed.
fix
Install required plugins explicitly, e.g., `yarn add markdown-it-anchor`.
affects: >=0.0.0
deprecatedThe `body` property on content object is deprecated; use `html` or raw markdown input.
fix
Access `content.html` for compiled output; the original markdown is the input string.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: MarkdownItCompiler is not a constructor
Default import used instead of named import.
fix
Change to `import { MarkdownItCompiler } from 'markdown-it-compiler'`.
Cannot find module 'markdown-it-abbr'
Plugin referenced by string name but not installed.
fix
Run `yarn add markdown-it-abbr` or install the plugin package.
TypeError: compiler.compile is not a function
Compiler instance created without new keyword or with wrong config shape.
fix
Ensure correct instantiation: `const compiler = new MarkdownItCompiler({...})` and config is an object.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
markdown-itrequiredpeer dependency for core Markdown parsing
Agent activity
2 hits · last 30 days
node
2
Resources
markdown-it-compiler — npm install markdown-it-compiler · libregistry