highlightjs-curl
A highlight.js language grammar module that adds cURL command syntax highlighting to any site or app.
Repository Health
Technical Analysis
highlightjs-curl is a third-party language grammar for highlight.js that teaches it to recognize and syntax-highlight cURL command-line invocations. Because cURL syntax overlaps heavily with shell/bash, highlight.js’s auto-detection can misclassify it without an explicit grammar, so this module registers a dedicated curl language that correctly highlights flags, URLs, headers, and other cURL-specific tokens.
It’s distributed as a standalone module (not bundled in highlight.js core) that you load and register with hljs.registerLanguage(), and it ships both a CommonJS/ESM source module for bundlers and a pre-built minified dist/curl.min.js for direct script-tag or CDN use.
What You Get
- A
curllanguage grammar module compatible withhljs.registerLanguage() - A pre-built minified bundle (
dist/curl.min.js) for direct<script>tag or CDN use - Correct highlighting of cURL flags, URLs, headers, and other command-specific tokens distinct from plain bash
- A Jasmine-based test suite with markup/detect fixtures for grammar regression testing
- Compatibility with Node/Webpack/Rollup/Browserify bundlers via
require()/import
Common Use Cases
- Highlighting cURL command examples in API documentation or developer portal code blocks
- Adding accurate curl syntax highlighting to a technical blog or static site using highlight.js
- Rendering markdown-based docs (e.g. via a static site generator) with proper curl code fences
- Supplementing highlight.js’s core language set for projects heavy on HTTP/API usage examples
Under The Hood
Architecture The module defines a single language grammar object in src/languages/curl.js describing the tokens, keywords, and highlighting rules highlight.js needs to parse cURL invocations, which is registered into a running highlight.js instance via hljs.registerLanguage("curl", hljsCurl) rather than shipping its own rendering engine. Tech Stack It’s a small, dependency-free JavaScript module with highlight.js itself as a peer dependency (not bundled), distributed as both an npm package (main: src/languages/curl.js) and a pre-built minified UMD bundle in dist/ for CDN consumption. Code Quality The grammar is covered by a Jasmine test suite (spec/curl-spec.js) plus fixture-based test/markup and test/detect files that verify both correct tokenization and language auto-detection behavior, following highlight.js’s own third-party plugin conventions; the project sees infrequent updates befitting a narrow, stable grammar definition. API Design The integration surface is minimal by design — one registerLanguage call — matching highlight.js’s own plugin convention, so adopting it requires no API to learn beyond marking code blocks with the language-curl class.
Used by 2 apps in this directory
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.
Supabase
Developer Tools · Databases · Search
The open-source Postgres development platform that replaces Firebase with authentication, real-time APIs, edge functions, storage, and vector embeddings — all built on PostgreSQL.