Registry / http-networking / vite-plugin-tdoc

vite-plugin-tdoc

JSON →
library2.0.4jsnpmunverified

vite-plugin-tdoc (version 2.0.4) is a Vite plugin that transforms Markdown files into anything (e.g., HTML, Vue components) during the build process. Inspired by VitePress, it provides hooks for custom Markdown processing using markdown-it and its ecosystem (containers, attributes, anchors, TOC). It supports before/render/after transforms and can integrate additional Vite plugins. Released under MIT license. The plugin is actively maintained, with a focus on flexibility and developer control over Markdown transformation.

npm install vite-plugin-tdoc
INSTALL
IMPORT
SIG · VITE-PLUGIN-TDOC
V
vite-plugin-tdoc
http-networkingjavascriptv2.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

default
import vitePluginTdoc from 'vite-plugin-tdoc'
const vitePluginTdoc = require('vite-plugin-tdoc')
ESM only; CommonJS require() will fail in Vite.
vitePluginTdoc
import vitePluginTdoc from 'vite-plugin-tdoc'
import { vitePluginTdoc } from 'vite-plugin-tdoc'
Default export only, not named.
Type definitions
import type { Options } from 'vite-plugin-tdoc'
TypeScript users can import Options type for configuration.

Shows basic Vite config with vitePluginTdoc, enabling line numbers, anchor links, custom markdown-it plugins, and a before transform to strip HTML comments.

// vite.config.ts import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import vitePluginTdoc from 'vite-plugin-tdoc' export default defineConfig({ plugins: [ vue(), vitePluginTdoc({ markdown: { lineNumbers: true, anchor: { permalink: true }, config(md) { md.use(require('markdown-it-emoji')) } }, transforms: { before({ source }) { return source.replace(/<!--.*?-->/gs, '') } } }) ] })
Debug
Known issues
gotchaUsing require() in config file will cause ESM/CJS mismatch in Vite.
fix
Use dynamic import() instead of require() in config, or mark package as type: module.
affects: >=2.0.0
gotchamarkdown-it-attrs may conflict with markdown-it-container syntax if both are used carelessly.
fix
Ensure custom container syntax does not interfere with attribute syntax; test combinations.
affects: >=1.0.0
deprecatedOptions like 'markdown.anchor' and 'markdown.toc' may be deprecated in future versions.
fix
Check release notes for migration to direct markdown-it plugin usage.
affects: >=2.0.0
gotchaThe plugin does not work with CommonJS Vite configs (e.g., vite.config.js using module.exports).
fix
Use ES module syntax (export default) in vite config.
affects: >=2.0.0
gotchaTransforms 'before', 'render', 'after' must return a string or undefined; returning null/object may break.
fix
Always return a string from transform hooks or undefined to skip modification.
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: Unexpected token 'export'
Using CommonJS require() to load vite-plugin-tdoc in a CJS context.
fix
Switch vite.config to ES module (type: 'module' in package.json) and use import syntax.
Error: Cannot find module 'markdown-it-container'
Optional peer dependency markdown-it-container not installed.
fix
Install the optional dependencies: npm install markdown-it-container markdown-it-attrs markdown-it-anchor markdown-it-toc-done-right
TypeError: md.use is not a function
Trying to call md.use before markdown-it is initialized in config callback.
fix
Use the config callback correctly: config(md) { md.use(require('markdown-it-emoji')) }
Upgrade
Version history
2.0.4latest on npm
Audit
Dependencies
markdown-itrequiredCore Markdown parser used for transforming markdown content.
markdown-it-containeroptionalPlugin for custom containers in markdown.
markdown-it-attrsoptionalPlugin for adding attributes to markdown elements.
markdown-it-anchoroptionalPlugin for adding anchors to headings.
markdown-it-toc-done-rightoptionalPlugin for generating table of contents.
Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
vite-plugin-tdoc — npm install vite-plugin-tdoc · libregistry