Repository navigation
remove-markdown 0.8.0
This minor release adds an opt-in stripMdxImports option for cleaner excerpts
from MDX documents. The option defaults to false, preserving existing Markdown
output unless callers explicitly enable it.
const removeMd = require('remove-markdown');
const markdown = 'import { Card, Button } from "./components";\n\n# Welcome';
const plainText = removeMd(markdown, { stripMdxImports: true });
// WelcomeMDX import stripping
- Removes a leading block of default, named, namespace, or side-effect imports.
- Supports multiline named imports, aliases, trailing commas, optional
semicolons, trailing spaces and tabs, LF/CRLF line endings, and EOF. - Preserves ordinary list content and code-block contents through the existing
Markdown-stripping behavior. - Stops at other content or unsupported import syntax, including comments and
import attributes. Imports after headings or other content remain in the output.
The option is available in CommonJS and ESM, with matching TypeScript declarations.
No runtime dependencies were added.
Compatibility and validation
- Existing callers do not need to change their code; the new option is disabled
by default. - Added 24 regression tests, bringing the behavior suite to 68 tests.
- Verified unchanged output in 66,000 CommonJS/ESM comparisons against 0.7.1 with
the option omitted or disabled. - The feature passed CI on Node.js 18, 20, 22, 24, and 26, Deno 2, and package
checks on Linux, macOS, and Windows, along with TypeScript and bundler checks.
Because this is a 0.x minor release, dependency ranges such as ^0.7.1 do not
automatically include 0.8.0. Update the range explicitly to adopt this release.
Thanks to @Strokkur424 for proposing and
implementing this feature and working through the compatibility review in
#113.
npm install remove-markdown@0.8.0