highlightjs-curl

A highlight.js language grammar module that adds cURL command syntax highlighting to any site or app.

Library
npm
v1.3.0
8stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
22/100Needs Attention
Development Activity0
Maintenance20
Community8
Maturity60
Momentum0

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
56/100Fair
Architecture50
Code Quality58
Innovation35
Learning Curve80

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 curl language grammar module compatible with hljs.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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search