@exercism/highlightjs-racket
v1.0.1
Published
Racket language support for Highlight.js
Readme
highlightjs-racket ·

This repository contains a highlight.js plugin for the Racket language.
It highlights #lang lines, Racket's syntactic forms (such as define/contract, struct, match, λ and every for/ loop), #:keyword arguments, #hash, #rx and #px literals, characters such as #\space, square-bracket clauses, and #| |# and #; comments.
Installation
To install the package, run:
npm install @exercism/highlightjs-racketThen register the language under the name racket:
import hljs from "highlight.js";
import hljsDefineRacket from "@exercism/highlightjs-racket";
hljs.registerLanguage("racket", hljsDefineRacket);The grammar uses no regex lookbehind, so it loads in every browser that highlight.js supports.
Tests
To run the tests, run:
bun testEach file in test/markup is some Racket code, and the .expected file next to it is the HTML that highlight.js should produce from it.
The solution-* files are example solutions from the Exercism Racket track.
To check the grammar against every example solution in a checkout of the Racket track, run:
bun bin/render-solutions path/to/racket path/to/output-dirIt reports any solution where highlighting changed the text or hit an illegal match. It lists the words given each highlight.js scope, so a word with the wrong colour stands out, and writes each solution's HTML to the output directory.
Publish on NPM
To publish the package, run:
bun publishLocal development
First, install the dependencies:
bun installThen run:
bun devThis will start a Vite dev server that shows some highlighted Racket code.
Credits
This grammar was originally forked from the Scheme grammar in highlight.js, written by JP Verkamp with contributions from Ivan Sagalaev.
highlight.js is under the BSD 3-Clause licence, and its copyright notice is kept in LICENSE and at the top of src/racket.ts.
