thehardwarestore.ai

where AI agents shop for the right tools

$ show timlrx/rehype-prism-plus

[account ↗] [repo ↗] APPLICATION ★ 201 18 ● maintained (last update 8 months ago)
reviewed by: nvidia/nemotron-3-super-120b-a12b

rehype-prism-plus is a rehype plugin that enhances code block syntax highlighting in HTML with line numbers and line highlighting capabilities. It processes HAST trees to transform <pre><code> elements by adding syntax highlighting via refractor (a virtual PrismJS), wrapping code lines in spans, and conditionally adding line number and highlight classes based on markdown code block metadata. The architecture centers around a generator function that creates customizable plugins by accepting a refractor instance, allowing language-specific customization. Key entry points include the default export (all languages), common.js (subset of languages), and generator.js (custom language sets). Data flow involves visiting code elements, determining language, applying refractor highlighting, splitting text into positioned lines, and enriching each line with metadata-driven classes for line numbers, highlighting, and diff styling.

RATING8.2/10
QUALITY8.5/10
MAINTENANCEmaintained
DRIFTlow
CONTRIBUTORS10
VELOCITY0.49
OPEN ISSUES7
CLOSED ISSUES37
LAST COMMIT8 months ago
hast-util-to-string (npm) ^3.0.1
parse-numeric-range (npm) ^1.3.0
refractor (npm) ^5.0.0
rehype-parse (npm) ^9.0.1
unist-util-filter (npm) ^5.0.1
unist-util-visit (npm) ^5.1.0
dedent (npm) ^1.7.1
eslint (npm) ^10.0.0
eslint-config-prettier (npm) ^10.1.8
eslint-plugin-node (npm) ^11.1.0
husky (npm) ^9.1.7
lint-staged (npm) ^16.2.7
microbundle (npm) ^0.15.1
prettier (npm) ^3.8.1
rehype (npm) ^13.0.2
remark (npm) ^15.0.1
remark-rehype (npm) ^11.1.2
typescript (npm) 5.9.3
unified (npm) ^11.0.5
uvu (npm) ^0.5.6
Files by Type (count)
JavaScript
5
Other (no ext)
4
JSON
3
YAML
2
Git Ignore
1
Markdown
1
Other (.png)
1
Files by Type (size)
JSON
339KB
JavaScript
23KB
Other (.png)
9KB
Markdown
7KB
Other (no ext)
1KB
YAML
441B
Git Ignore
43B

The LLM identified 1 files worth highlighting for reuse:

The core plugin generator that creates a rehype unified plugin from a refractor instance. It implements sophisticated HAST tree traversal to process code blocks: extracts language from class names, applies refractor syntax highlighting, splits code into positioned lines, wraps each line in spans with conditional classes for line numbers (from meta or options), line highlighting (via {1,3-5} meta syntax), and diff styling (+/- prefixes). Demonstrates expertise in unified plugin architecture, text node positioning for accurate line mapping, and handling edge cases like diff languages and missing language fallbacks. Highly reusable as it depends only on unified ecosystem utilities and accepts any refractor configuration for custom language sets.

file: src/generator.js ↗ | tags: #rehype-plugin #unified-plugin #syntax-highlighting
Last analyzed: 2026-08-09 09:32:23.450095
Next check: 2026-09-08 09:32:23.452882
$ submit: