{"id":20327,"library":"prettier-markdown","title":"prettier-markdown","description":"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.","status":"maintenance","version":"0.1.8","language":"javascript","source_language":"en","source_url":"https://github.com/noyobo/prettier-markdown","tags":["javascript","prettier","markdown","formater"],"install":[{"cmd":"npm install prettier-markdown","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-markdown","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-markdown","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used to format JavaScript code blocks; expected to be installed as a peer or direct dependency","package":"prettier","optional":false},{"reason":"Used for file globbing in CLI","package":"glob","optional":true},{"reason":"Used to parse and modify Markdown AST","package":"remark","optional":false}],"imports":[{"note":"Package does not have TypeScript types; use dynamic import or require as fallback.","wrong":"const prettierMarkdown = require('prettier-markdown');","symbol":"default","correct":"import prettierMarkdown from 'prettier-markdown';"},{"note":"Package exports a single default function; named export does not exist.","wrong":"const { prettierMarkdown } = require('prettier-markdown');","symbol":"prettierMarkdown (named)","correct":"import { prettierMarkdown } from 'prettier-markdown';"},{"note":"CommonJS works fine.","wrong":"","symbol":"require","correct":"const prettierMarkdown = require('prettier-markdown');"}],"quickstart":{"code":"// CLI usage\n// prettier-markdown ./**/*.md\n// pmd ./**/*.md\n\n// Programmatic API\nconst prettierMarkdown = require('prettier-markdown');\n\n// With callback\nprettierMarkdown('./foo.md', function(err, msg) {\n  if (err) console.error(err);\n  else console.log(msg);\n});\n\n// With Promise\nconst promise = prettierMarkdown('./foo.md', {\n  // options here\n});\npromise.then(msg => console.log(msg)).catch(err => console.error(err));","lang":"javascript","description":"Shows CLI command and programmatic usage with callback and Promise patterns."},"warnings":[{"fix":"Consider using prettier-plugin-md or markdown-magic-prettier instead.","message":"Package has not been updated in years; may not work with newer Prettier versions.","severity":"deprecated","affected_versions":">=0.1.8"},{"fix":"Check Markdown validity; consider using a dedicated Prettier plugin.","message":"The package uses remark internally; if your Markdown uses non-standard syntax, formatting may break.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use // @ts-ignore or declare module 'prettier-markdown'.","message":"No TypeScript definitions; TypeScript users must use require or create custom types.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install prettier' in your project.","cause":"prettier is a peer dependency not automatically installed.","error":"Error: Cannot find module 'prettier'"},{"fix":"Use 'const prettierMarkdown = require('prettier-markdown');' or 'import prettierMarkdown from 'prettier-markdown';'","cause":"Using named import where default is expected.","error":"TypeError: prettierMarkdown is not a function"},{"fix":"Use require() or configure your bundler/Node to handle CommonJS.","cause":"The package does not support ES modules natively.","error":"SyntaxError: Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}