markdown-magic-prettier
July 5, 2026 ยท View on GitHub
๐ฆ This package has moved. It now lives in the markdown-magic-plugins monorepo at
packages/prettier. This repository is archived; issues and contributions go to the monorepo.
markdown-magic-prettier
Use prettier to format JS codeblocks in markdown files via markdown-magic
Install
yarn add -D markdown-magic markdown-magic-prettier prettier
Note: prettier is a peer dependency and must be installed separately from this module
Adding the plugin
See example.js for usage.
import path from 'path';
import { markdownMagic } from 'markdown-magic';
import PRETTIER from './index.js';
const config = {
matchWord: 'AUTO-GENERATED-CONTENT',
transforms: {
PRETTIER,
},
};
const markdownPath = path.join(import.meta.dirname, 'README.md');
await markdownMagic(markdownPath, config);
Usage in markdown
Wrap code blocks to format the content.
console.log('hello world');
Options
All prettier options are supported.
There are a few defaults set:
const defaults = {
singleQuote: true,
trailingComma: 'es5',
};