Registry / testing / prettier-markdown

prettier-markdown

JSON →
library0.1.8jsnpmunverified

Prettier is a popular code formatter, but it does not format JavaScript code embedded in Markdown files out of the box. prettier-markdown fills this gap by parsing Markdown files, extracting JavaScript code blocks, applying Prettier formatting, and writing the formatted code back into the Markdown. Version 0.1.8 is the latest stable release, but development appears to be dormant (last commit years ago). It provides both a CLI (with short command `pmd`) and a programmatic API returning Promises or using callbacks. Alternative tools include `prettier-plugin-md` (Prettier plugin) or `markdown-magic-prettier`, but this package offers a standalone solution.

npm install prettier-markdown
INSTALL
IMPORT
SIG · PRETTIER-MARKDOWN
P
prettier-markdown
testingjavascriptv0.1.8
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
import prettierMarkdown from 'prettier-markdown';
const prettierMarkdown = require('prettier-markdown');
Package does not have TypeScript types; use dynamic import or require as fallback.
prettierMarkdown (named)
import { prettierMarkdown } from 'prettier-markdown';
const { prettierMarkdown } = require('prettier-markdown');
Package exports a single default function; named export does not exist.
require
const prettierMarkdown = require('prettier-markdown');
CommonJS works fine.

Shows CLI command and programmatic usage with callback and Promise patterns.

// CLI usage // prettier-markdown ./**/*.md // pmd ./**/*.md // Programmatic API const prettierMarkdown = require('prettier-markdown'); // With callback prettierMarkdown('./foo.md', function(err, msg) { if (err) console.error(err); else console.log(msg); }); // With Promise const promise = prettierMarkdown('./foo.md', { // options here }); promise.then(msg => console.log(msg)).catch(err => console.error(err));
pmd --version
Debug
Known issues
deprecatedPackage has not been updated in years; may not work with newer Prettier versions.
fix
Consider using prettier-plugin-md or markdown-magic-prettier instead.
affects: >=0.1.8
gotchaThe package uses remark internally; if your Markdown uses non-standard syntax, formatting may break.
fix
Check Markdown validity; consider using a dedicated Prettier plugin.
affects: >=0.0.0
gotchaNo TypeScript definitions; TypeScript users must use require or create custom types.
fix
Use // @ts-ignore or declare module 'prettier-markdown'.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'prettier'
prettier is a peer dependency not automatically installed.
fix
Run 'npm install prettier' in your project.
TypeError: prettierMarkdown is not a function
Using named import where default is expected.
fix
Use 'const prettierMarkdown = require('prettier-markdown');' or 'import prettierMarkdown from 'prettier-markdown';'
SyntaxError: Unexpected token 'export'
The package does not support ES modules natively.
fix
Use require() or configure your bundler/Node to handle CommonJS.
Upgrade
Version history
0.1.8latest on npm
Audit
Dependencies
prettierrequiredUsed to format JavaScript code blocks; expected to be installed as a peer or direct dependency
globoptionalUsed for file globbing in CLI
remarkrequiredUsed to parse and modify Markdown AST
Agent activity
12 hits · last 30 days
node
12
Resources
prettier-markdown — npm install prettier-markdown · libregistry