Something went wrong. Try again.
A monorepo for writing specs and other serious text on the AT Protocol.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748// The languages code blocks highlight (a curated subset of highlight.js).import bash from 'highlight.js/lib/languages/bash';import c from 'highlight.js/lib/languages/c';import css from 'highlight.js/lib/languages/css';import go from 'highlight.js/lib/languages/go';import javascript from 'highlight.js/lib/languages/javascript';import json from 'highlight.js/lib/languages/json';import markdown from 'highlight.js/lib/languages/markdown';import plaintext from 'highlight.js/lib/languages/plaintext';import python from 'highlight.js/lib/languages/python';import rust from 'highlight.js/lib/languages/rust';import typescript from 'highlight.js/lib/languages/typescript';import xml from 'highlight.js/lib/languages/xml';import yaml from 'highlight.js/lib/languages/yaml';import { createLowlight } from 'lowlight';
export const LANGUAGES = { bash, c, css, go, javascript, json, markdown, plaintext, python, rust, typescript, xml, yaml };
export const ALIASES: Record<string, string> = { js: 'javascript', mjs: 'javascript', cjs: 'javascript', ts: 'typescript', mts: 'typescript', html: 'xml', svg: 'xml', sh: 'bash', shell: 'bash', zsh: 'bash', yml: 'yaml', md: 'markdown', py: 'python', rs: 'rust', text: 'plaintext', txt: 'plaintext',};
export function canonicalLanguage(language: string | undefined): string | undefined { if (!language) return undefined; const l = language.trim().toLowerCase(); if (l in LANGUAGES) return l; return ALIASES[l];}
export const lowlight = createLowlight();for (const [name, grammar] of Object.entries(LANGUAGES)) lowlight.register(name, grammar);for (const [alias, name] of Object.entries(ALIASES)) lowlight.registerAlias(name, alias);