$ show markedjs/marked
marked is a high-performance Markdown parser and compiler written in TypeScript, designed for speed and extensibility. It converts Markdown text into HTML, supporting the CommonMark specification and GitHub Flavored Markdown (GFM) extensions such as tables, task lists, strikethrough, and autolinks. The library is used both as a Node.js package (ESM and UMD builds) and as a command-line tool (bin/marked). Its architecture is modular, consisting of a Lexer (tokenization), Parser (AST construction), Renderer (HTML output), and an extension system via Hooks and custom tokenizers. The core entry point is the `marked()` function, which accepts a Markdown string and options, and returns HTML. The library also exposes a `Marked` class for more control, including async parsing, token walking, and plugin integration. marked does not sanitize output HTML, leaving XSS prevention to downstream consumers. The project includes an extensive test suite with over 600 CommonMark spec examples, GFM spec tests, and custom regression/performance tests (including ReDoS mitigation). The CLI supports stdin, file input, and config files, making it suitable for scripting and build pipelines.
The LLM identified 2 files worth highlighting for reuse:
A collection of pure, self-contained utility functions for HTML entity escaping, URL cleaning, label normalization, whitespace trimming, and table cell splitting. These functions are used throughout the parser but have no internal dependencies on the rest of marked, making them easily extractable into any web project that needs robust string manipulation for HTML or Markdown processing.
Defines a generic hook pipeline class that manages preprocess, postprocess, processAllTokens, emStrongMask, provideLexer, and provideParser hooks. It supports adding, removing, and running hooks in order, with async support. This pattern is isolated from the rest of marked and could be reused as a standalone hook/plugin system for any processing pipeline, demonstrating clean design for extensibility.