{"library":"marked","title":"Marked.js Markdown Parser","description":"Marked.js is a high-performance Markdown parser designed to efficiently convert Markdown text into HTML. It is currently at version 18.0.2 and maintains a very active release cadence, with frequent patch and minor versions often released weekly or bi-weekly, and major versions arriving every few months. Key differentiators include its strong focus on speed, its architecture as a low-level compiler that avoids caching and prolonged blocking operations, and its lightweight footprint. It aims to implement all Markdown features from supported specifications and is versatile, capable of running in browser environments, on a server (Node.js), or via its command-line interface. A critical consideration for users is that Marked.js intentionally does *not* sanitize its HTML output, necessitating the integration of a separate sanitization library like DOMPurify for any security-sensitive applications.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install marked"],"cli":{"name":"marked","version":null}},"imports":["import { marked } from 'marked';","import { parse } from 'marked';","import type { MarkedExtension } from 'marked';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { marked } from 'marked';\nimport DOMPurify from 'dompurify';\n\nconst markdownInput = `# Hello from Marked.js!\n\nThis is a paragraph with **bold** and *italic* text.\n\n- List item 1\n- List item 2\n\n### Code Example\n\n```javascript\nfunction greet(name) {\n  console.log('Hello, ' + name + '!');\n}\ngreet('World');\n```\n\n<script>alert('XSS attempt!');</script>`;\n\n// Parse the markdown to HTML\nconst unsafeHTML = marked.parse(markdownInput);\n\n// Sanitize the HTML output (CRITICAL STEP for untrusted input)\nconst safeHTML = DOMPurify.sanitize(unsafeHTML);\n\nconsole.log('--- Unsafe HTML (for demonstration) ---\\n', unsafeHTML);\nconsole.log('\\n--- Safe HTML (after DOMPurify) ---\\n', safeHTML);\n\n// Example with custom options\nmarked.setOptions({\n  gfm: true, // GitHub Flavored Markdown\n  breaks: true, // Interpret line breaks as <br/>\n  headerIds: false // Disable auto-generated header IDs\n});\n\nconst customParsedHTML = DOMPurify.sanitize(marked.parse(`## Custom Options Test\\nLine 1\\nLine 2`));\nconsole.log('\\n--- HTML with Custom Options ---\\n', customParsedHTML);\n","lang":"typescript","description":"Demonstrates basic Markdown parsing with Marked.js, including critical HTML sanitization using DOMPurify and configuring options.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}