{"id":20387,"library":"prettier-plugin-marko","title":"prettier-plugin-marko","description":"Prettier plugin for formatting Marko template files. Current stable version is 4.0.9, released February 2026. This plugin is maintained by the Marko team and is the official formatter for Marko files. It supports both HTML-like and concise syntax, auto-detecting the syntax used. It integrates with Prettier's CLI and editor plugins. Breaking change in v4.0.0: text adjacent to tags now prints on the same line when possible. Requires prettier v3 or later; for prettier@2, use version 2.x. Ships TypeScript types and has active patch releases.","status":"active","version":"4.0.9","language":"javascript","source_language":"en","source_url":"https://github.com/marko-js/prettier","tags":["javascript","format","marko","prettier","prettyprint","typescript"],"install":[{"cmd":"npm install prettier-plugin-marko","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-marko","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-marko","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: the plugin requires Prettier to be installed","package":"prettier","optional":false}],"imports":[{"note":"The plugin is not imported in user code; it's referenced in Prettier configuration (e.g., .prettierrc or CLI --plugin). No JavaScript import needed.","wrong":"// Do not import directly in code; the plugin is loaded by Prettier's config","symbol":"default plugin","correct":"// In .prettierrc: { \"plugins\": [\"prettier-plugin-marko\"] }"},{"note":"Use full package name to avoid conflict with other plugins.","wrong":"npx prettier --write \"**/*.marko\" --plugin=marko","symbol":"Usage with CLI","correct":"npx prettier --write \"**/*.marko\" --plugin=prettier-plugin-marko"},{"note":"Ensure plugins array is top-level in config. Also supports markoSyntax option.","wrong":"// .prettierrc\n{ \"plugins\": [\"prettier-plugin-marko\"] } // This is correct, but many forget to add the plugin array.","symbol":"Config file example","correct":"// .prettierrc\n{ \"plugins\": [\"prettier-plugin-marko\"] }"}],"quickstart":{"code":"// Install dependencies\nnpm install --save-dev prettier prettier-plugin-marko\n\n// Create .prettierrc\ncat << EOF > .prettierrc\n{\n  \"plugins\": [\"prettier-plugin-marko\"],\n  \"markoSyntax\": \"auto\"\n}\nEOF\n\n// Create a sample Marko file\ncat << EOF > example.marko\n<div>\n    <p>  Hello World  </p>\n</div>\nEOF\n\n// Format the file\nnpx prettier --write example.marko","lang":"typescript","description":"Shows minimal setup: install packages, configure Prettier, create a Marko file, and format it."},"warnings":[{"fix":"If you rely on previous formatting with separate lines, update your code or consider using markoSyntax: 'concise' to avoid auto-detection.","message":"Text adjacent to tags in HTML mode now prints on the same line when possible (v4.0.0).","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Explicitly set markoSyntax option to 'html' or 'concise' in .prettierrc.","message":"The plugin auto-detects syntax (HTML vs concise) by default. This may lead to inconsistent formatting if some files are HTML and others concise.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Use prettier@3+ with prettier-plugin-marko@4, or prettier@2 with prettier-plugin-marko@2.","message":"Version 2.x works with prettier@2. Using version 4.x with prettier@2 will fail.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Update to v4.0.5 or later to preserve $!{} placeholders.","message":"The plugin may change whitespace around placeholders like $!{} (v4.0.5 preserves them, but earlier versions might collapse).","severity":"gotcha","affected_versions":"<4.0.5"},{"fix":"Update to v4.0.8+ to ensure static block positions are kept.","message":"Static block locations are preserved in v4.0.8, but previous versions might have reformatted them incorrectly.","severity":"gotcha","affected_versions":"<4.0.8"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install --save-dev prettier-plugin-marko and ensure .prettierrc contains 'plugins': ['prettier-plugin-marko'].","cause":"Plugin not installed or not referenced correctly in config.","error":"Error: Could not find plugin \"prettier-plugin-marko\""},{"fix":"Install locally: npm install --save-dev prettier-plugin-marko. If using global prettier, install plugin globally too: npm install -g prettier-plugin-marko.","cause":"Plugin not installed or installed in wrong directory (e.g., global vs local).","error":"Error: Cannot find module 'prettier-plugin-marko' from '...'"},{"fix":"Upgrade Prettier to v3+ or downgrade plugin to v2.","cause":"Using a version of Prettier that is incompatible (e.g., prettier@2 with plugin@4).","error":"TypeError: prettier.resolveConfig is not a function"},{"fix":"Update the plugin to the latest version: npm install prettier-plugin-marko@latest.","cause":"The file contains syntax not supported by the Marko parser version used by the plugin.","error":"Unexpected token: ... in file.marko"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}