Comparing version 2.9.0 to 3.0.0
@@ -1,4 +0,22 @@ | ||
export {lowlight} from './lib/common.js' | ||
export type Root = import('./lib/core.js').Root | ||
export type Options = import('./lib/core.js').Options | ||
export type AutoOptions = import('./lib/core.js').AutoOptions | ||
export type {LanguageFn} from 'highlight.js' | ||
export type {AutoOptions, Options} from './lib/index.js' | ||
export {grammars as all} from './lib/all.js' | ||
export {grammars as common} from './lib/common.js' | ||
export {createLowlight} from './lib/index.js' | ||
// Register data on hast. | ||
declare module 'hast' { | ||
interface RootData { | ||
/** | ||
* Field exposed by `lowlight` to contain the detected programming language | ||
* name. | ||
*/ | ||
language?: string | undefined | ||
/** | ||
* Field exposed by `lowlight` to contain a relevance: how sure `lowlight` | ||
* is that the given code is in the language. | ||
*/ | ||
relevance?: number | undefined | ||
} | ||
} |
11
index.js
@@ -1,7 +0,4 @@ | ||
/** | ||
* @typedef {import('./lib/core.js').Root} Root | ||
* @typedef {import('./lib/core.js').Options} Options | ||
* @typedef {import('./lib/core.js').AutoOptions} AutoOptions | ||
*/ | ||
export {lowlight} from './lib/common.js' | ||
// Note: types exposed from `index.d.ts`. | ||
export {grammars as all} from './lib/all.js' | ||
export {grammars as common} from './lib/common.js' | ||
export {createLowlight} from './lib/index.js' |
@@ -1,2 +0,7 @@ | ||
export {lowlight} from './common.js' | ||
export type DoNotTochItRegistersLanguageFiles = any | ||
/** | ||
* Map of grammars. | ||
* | ||
* @type {Record<string, LanguageFn>} | ||
*/ | ||
export const grammars: Record<string, LanguageFn>; | ||
export type LanguageFn = import('highlight.js').LanguageFn; |
327
lib/all.js
@@ -1,3 +0,4 @@ | ||
// @ts-expect-error: this registers types for the language files. | ||
/** @typedef {import('highlight.js/types/index.js')} DoNotTochItRegistersLanguageFiles */ | ||
/** | ||
* @typedef {import('highlight.js').LanguageFn} LanguageFn | ||
*/ | ||
@@ -159,160 +160,166 @@ import $1c from 'highlight.js/lib/languages/1c' | ||
import zephir from 'highlight.js/lib/languages/zephir' | ||
import {lowlight} from './common.js' | ||
import {grammars as base} from './common.js' | ||
lowlight.registerLanguage('1c', $1c) | ||
lowlight.registerLanguage('abnf', abnf) | ||
lowlight.registerLanguage('accesslog', accesslog) | ||
lowlight.registerLanguage('actionscript', actionscript) | ||
lowlight.registerLanguage('ada', ada) | ||
lowlight.registerLanguage('angelscript', angelscript) | ||
lowlight.registerLanguage('apache', apache) | ||
lowlight.registerLanguage('applescript', applescript) | ||
lowlight.registerLanguage('arcade', arcade) | ||
lowlight.registerLanguage('armasm', armasm) | ||
lowlight.registerLanguage('asciidoc', asciidoc) | ||
lowlight.registerLanguage('aspectj', aspectj) | ||
lowlight.registerLanguage('autohotkey', autohotkey) | ||
lowlight.registerLanguage('autoit', autoit) | ||
lowlight.registerLanguage('avrasm', avrasm) | ||
lowlight.registerLanguage('awk', awk) | ||
lowlight.registerLanguage('axapta', axapta) | ||
lowlight.registerLanguage('basic', basic) | ||
lowlight.registerLanguage('bnf', bnf) | ||
lowlight.registerLanguage('brainfuck', brainfuck) | ||
lowlight.registerLanguage('cal', cal) | ||
lowlight.registerLanguage('capnproto', capnproto) | ||
lowlight.registerLanguage('ceylon', ceylon) | ||
lowlight.registerLanguage('clean', clean) | ||
lowlight.registerLanguage('clojure', clojure) | ||
lowlight.registerLanguage('clojure-repl', clojureRepl) | ||
lowlight.registerLanguage('cmake', cmake) | ||
lowlight.registerLanguage('coffeescript', coffeescript) | ||
lowlight.registerLanguage('coq', coq) | ||
lowlight.registerLanguage('cos', cos) | ||
lowlight.registerLanguage('crmsh', crmsh) | ||
lowlight.registerLanguage('crystal', crystal) | ||
lowlight.registerLanguage('csp', csp) | ||
lowlight.registerLanguage('d', d) | ||
lowlight.registerLanguage('dart', dart) | ||
lowlight.registerLanguage('delphi', delphi) | ||
lowlight.registerLanguage('django', django) | ||
lowlight.registerLanguage('dns', dns) | ||
lowlight.registerLanguage('dockerfile', dockerfile) | ||
lowlight.registerLanguage('dos', dos) | ||
lowlight.registerLanguage('dsconfig', dsconfig) | ||
lowlight.registerLanguage('dts', dts) | ||
lowlight.registerLanguage('dust', dust) | ||
lowlight.registerLanguage('ebnf', ebnf) | ||
lowlight.registerLanguage('elixir', elixir) | ||
lowlight.registerLanguage('elm', elm) | ||
lowlight.registerLanguage('erb', erb) | ||
lowlight.registerLanguage('erlang', erlang) | ||
lowlight.registerLanguage('erlang-repl', erlangRepl) | ||
lowlight.registerLanguage('excel', excel) | ||
lowlight.registerLanguage('fix', fix) | ||
lowlight.registerLanguage('flix', flix) | ||
lowlight.registerLanguage('fortran', fortran) | ||
lowlight.registerLanguage('fsharp', fsharp) | ||
lowlight.registerLanguage('gams', gams) | ||
lowlight.registerLanguage('gauss', gauss) | ||
lowlight.registerLanguage('gcode', gcode) | ||
lowlight.registerLanguage('gherkin', gherkin) | ||
lowlight.registerLanguage('glsl', glsl) | ||
lowlight.registerLanguage('gml', gml) | ||
lowlight.registerLanguage('golo', golo) | ||
lowlight.registerLanguage('gradle', gradle) | ||
lowlight.registerLanguage('groovy', groovy) | ||
lowlight.registerLanguage('haml', haml) | ||
lowlight.registerLanguage('handlebars', handlebars) | ||
lowlight.registerLanguage('haskell', haskell) | ||
lowlight.registerLanguage('haxe', haxe) | ||
lowlight.registerLanguage('hsp', hsp) | ||
lowlight.registerLanguage('http', http) | ||
lowlight.registerLanguage('hy', hy) | ||
lowlight.registerLanguage('inform7', inform7) | ||
lowlight.registerLanguage('irpf90', irpf90) | ||
lowlight.registerLanguage('isbl', isbl) | ||
lowlight.registerLanguage('jboss-cli', jbossCli) | ||
lowlight.registerLanguage('julia', julia) | ||
lowlight.registerLanguage('julia-repl', juliaRepl) | ||
lowlight.registerLanguage('lasso', lasso) | ||
lowlight.registerLanguage('latex', latex) | ||
lowlight.registerLanguage('ldif', ldif) | ||
lowlight.registerLanguage('leaf', leaf) | ||
lowlight.registerLanguage('lisp', lisp) | ||
lowlight.registerLanguage('livecodeserver', livecodeserver) | ||
lowlight.registerLanguage('livescript', livescript) | ||
lowlight.registerLanguage('llvm', llvm) | ||
lowlight.registerLanguage('lsl', lsl) | ||
lowlight.registerLanguage('mathematica', mathematica) | ||
lowlight.registerLanguage('matlab', matlab) | ||
lowlight.registerLanguage('maxima', maxima) | ||
lowlight.registerLanguage('mel', mel) | ||
lowlight.registerLanguage('mercury', mercury) | ||
lowlight.registerLanguage('mipsasm', mipsasm) | ||
lowlight.registerLanguage('mizar', mizar) | ||
lowlight.registerLanguage('mojolicious', mojolicious) | ||
lowlight.registerLanguage('monkey', monkey) | ||
lowlight.registerLanguage('moonscript', moonscript) | ||
lowlight.registerLanguage('n1ql', n1ql) | ||
lowlight.registerLanguage('nestedtext', nestedtext) | ||
lowlight.registerLanguage('nginx', nginx) | ||
lowlight.registerLanguage('nim', nim) | ||
lowlight.registerLanguage('nix', nix) | ||
lowlight.registerLanguage('node-repl', nodeRepl) | ||
lowlight.registerLanguage('nsis', nsis) | ||
lowlight.registerLanguage('ocaml', ocaml) | ||
lowlight.registerLanguage('openscad', openscad) | ||
lowlight.registerLanguage('oxygene', oxygene) | ||
lowlight.registerLanguage('parser3', parser3) | ||
lowlight.registerLanguage('pf', pf) | ||
lowlight.registerLanguage('pgsql', pgsql) | ||
lowlight.registerLanguage('pony', pony) | ||
lowlight.registerLanguage('powershell', powershell) | ||
lowlight.registerLanguage('processing', processing) | ||
lowlight.registerLanguage('profile', profile) | ||
lowlight.registerLanguage('prolog', prolog) | ||
lowlight.registerLanguage('properties', properties) | ||
lowlight.registerLanguage('protobuf', protobuf) | ||
lowlight.registerLanguage('puppet', puppet) | ||
lowlight.registerLanguage('purebasic', purebasic) | ||
lowlight.registerLanguage('q', q) | ||
lowlight.registerLanguage('qml', qml) | ||
lowlight.registerLanguage('reasonml', reasonml) | ||
lowlight.registerLanguage('rib', rib) | ||
lowlight.registerLanguage('roboconf', roboconf) | ||
lowlight.registerLanguage('routeros', routeros) | ||
lowlight.registerLanguage('rsl', rsl) | ||
lowlight.registerLanguage('ruleslanguage', ruleslanguage) | ||
lowlight.registerLanguage('sas', sas) | ||
lowlight.registerLanguage('scala', scala) | ||
lowlight.registerLanguage('scheme', scheme) | ||
lowlight.registerLanguage('scilab', scilab) | ||
lowlight.registerLanguage('smali', smali) | ||
lowlight.registerLanguage('smalltalk', smalltalk) | ||
lowlight.registerLanguage('sml', sml) | ||
lowlight.registerLanguage('sqf', sqf) | ||
lowlight.registerLanguage('stan', stan) | ||
lowlight.registerLanguage('stata', stata) | ||
lowlight.registerLanguage('step21', step21) | ||
lowlight.registerLanguage('stylus', stylus) | ||
lowlight.registerLanguage('subunit', subunit) | ||
lowlight.registerLanguage('taggerscript', taggerscript) | ||
lowlight.registerLanguage('tap', tap) | ||
lowlight.registerLanguage('tcl', tcl) | ||
lowlight.registerLanguage('thrift', thrift) | ||
lowlight.registerLanguage('tp', tp) | ||
lowlight.registerLanguage('twig', twig) | ||
lowlight.registerLanguage('vala', vala) | ||
lowlight.registerLanguage('vbscript', vbscript) | ||
lowlight.registerLanguage('vbscript-html', vbscriptHtml) | ||
lowlight.registerLanguage('verilog', verilog) | ||
lowlight.registerLanguage('vhdl', vhdl) | ||
lowlight.registerLanguage('vim', vim) | ||
lowlight.registerLanguage('wren', wren) | ||
lowlight.registerLanguage('x86asm', x86asm) | ||
lowlight.registerLanguage('xl', xl) | ||
lowlight.registerLanguage('xquery', xquery) | ||
lowlight.registerLanguage('zephir', zephir) | ||
export {lowlight} from './common.js' | ||
/** | ||
* Map of grammars. | ||
* | ||
* @type {Record<string, LanguageFn>} | ||
*/ | ||
export const grammars = { | ||
...base, | ||
'1c': $1c, | ||
abnf, | ||
accesslog, | ||
actionscript, | ||
ada, | ||
angelscript, | ||
apache, | ||
applescript, | ||
arcade, | ||
armasm, | ||
asciidoc, | ||
aspectj, | ||
autohotkey, | ||
autoit, | ||
avrasm, | ||
awk, | ||
axapta, | ||
basic, | ||
bnf, | ||
brainfuck, | ||
cal, | ||
capnproto, | ||
ceylon, | ||
clean, | ||
clojure, | ||
'clojure-repl': clojureRepl, | ||
cmake, | ||
coffeescript, | ||
coq, | ||
cos, | ||
crmsh, | ||
crystal, | ||
csp, | ||
d, | ||
dart, | ||
delphi, | ||
django, | ||
dns, | ||
dockerfile, | ||
dos, | ||
dsconfig, | ||
dts, | ||
dust, | ||
ebnf, | ||
elixir, | ||
elm, | ||
erb, | ||
erlang, | ||
'erlang-repl': erlangRepl, | ||
excel, | ||
fix, | ||
flix, | ||
fortran, | ||
fsharp, | ||
gams, | ||
gauss, | ||
gcode, | ||
gherkin, | ||
glsl, | ||
gml, | ||
golo, | ||
gradle, | ||
groovy, | ||
haml, | ||
handlebars, | ||
haskell, | ||
haxe, | ||
hsp, | ||
http, | ||
hy, | ||
inform7, | ||
irpf90, | ||
isbl, | ||
'jboss-cli': jbossCli, | ||
julia, | ||
'julia-repl': juliaRepl, | ||
lasso, | ||
latex, | ||
ldif, | ||
leaf, | ||
lisp, | ||
livecodeserver, | ||
livescript, | ||
llvm, | ||
lsl, | ||
mathematica, | ||
matlab, | ||
maxima, | ||
mel, | ||
mercury, | ||
mipsasm, | ||
mizar, | ||
mojolicious, | ||
monkey, | ||
moonscript, | ||
n1ql, | ||
nestedtext, | ||
nginx, | ||
nim, | ||
nix, | ||
'node-repl': nodeRepl, | ||
nsis, | ||
ocaml, | ||
openscad, | ||
oxygene, | ||
parser3, | ||
pf, | ||
pgsql, | ||
pony, | ||
powershell, | ||
processing, | ||
profile, | ||
prolog, | ||
properties, | ||
protobuf, | ||
puppet, | ||
purebasic, | ||
q, | ||
qml, | ||
reasonml, | ||
rib, | ||
roboconf, | ||
routeros, | ||
rsl, | ||
ruleslanguage, | ||
sas, | ||
scala, | ||
scheme, | ||
scilab, | ||
smali, | ||
smalltalk, | ||
sml, | ||
sqf, | ||
stan, | ||
stata, | ||
step21, | ||
stylus, | ||
subunit, | ||
taggerscript, | ||
tap, | ||
tcl, | ||
thrift, | ||
tp, | ||
twig, | ||
vala, | ||
vbscript, | ||
'vbscript-html': vbscriptHtml, | ||
verilog, | ||
vhdl, | ||
vim, | ||
wren, | ||
x86asm, | ||
xl, | ||
xquery, | ||
zephir | ||
} |
@@ -1,2 +0,7 @@ | ||
export {lowlight} from './core.js' | ||
export type DoNotTochItRegistersLanguageFiles = any | ||
/** | ||
* Map of grammars. | ||
* | ||
* @type {Record<string, LanguageFn>} | ||
*/ | ||
export const grammars: Record<string, LanguageFn>; | ||
export type LanguageFn = import('highlight.js').LanguageFn; |
@@ -1,3 +0,4 @@ | ||
// @ts-expect-error: this registers types for the language files. | ||
/** @typedef {import('highlight.js/types/index.js')} DoNotTochItRegistersLanguageFiles */ | ||
/** | ||
* @typedef {import('highlight.js').LanguageFn} LanguageFn | ||
*/ | ||
@@ -41,42 +42,46 @@ import arduino from 'highlight.js/lib/languages/arduino' | ||
import yaml from 'highlight.js/lib/languages/yaml' | ||
import {lowlight} from './core.js' | ||
lowlight.registerLanguage('arduino', arduino) | ||
lowlight.registerLanguage('bash', bash) | ||
lowlight.registerLanguage('c', c) | ||
lowlight.registerLanguage('cpp', cpp) | ||
lowlight.registerLanguage('csharp', csharp) | ||
lowlight.registerLanguage('css', css) | ||
lowlight.registerLanguage('diff', diff) | ||
lowlight.registerLanguage('go', go) | ||
lowlight.registerLanguage('graphql', graphql) | ||
lowlight.registerLanguage('ini', ini) | ||
lowlight.registerLanguage('java', java) | ||
lowlight.registerLanguage('javascript', javascript) | ||
lowlight.registerLanguage('json', json) | ||
lowlight.registerLanguage('kotlin', kotlin) | ||
lowlight.registerLanguage('less', less) | ||
lowlight.registerLanguage('lua', lua) | ||
lowlight.registerLanguage('makefile', makefile) | ||
lowlight.registerLanguage('markdown', markdown) | ||
lowlight.registerLanguage('objectivec', objectivec) | ||
lowlight.registerLanguage('perl', perl) | ||
lowlight.registerLanguage('php', php) | ||
lowlight.registerLanguage('php-template', phpTemplate) | ||
lowlight.registerLanguage('plaintext', plaintext) | ||
lowlight.registerLanguage('python', python) | ||
lowlight.registerLanguage('python-repl', pythonRepl) | ||
lowlight.registerLanguage('r', r) | ||
lowlight.registerLanguage('ruby', ruby) | ||
lowlight.registerLanguage('rust', rust) | ||
lowlight.registerLanguage('scss', scss) | ||
lowlight.registerLanguage('shell', shell) | ||
lowlight.registerLanguage('sql', sql) | ||
lowlight.registerLanguage('swift', swift) | ||
lowlight.registerLanguage('typescript', typescript) | ||
lowlight.registerLanguage('vbnet', vbnet) | ||
lowlight.registerLanguage('wasm', wasm) | ||
lowlight.registerLanguage('xml', xml) | ||
lowlight.registerLanguage('yaml', yaml) | ||
export {lowlight} from './core.js' | ||
/** | ||
* Map of grammars. | ||
* | ||
* @type {Record<string, LanguageFn>} | ||
*/ | ||
export const grammars = { | ||
arduino, | ||
bash, | ||
c, | ||
cpp, | ||
csharp, | ||
css, | ||
diff, | ||
go, | ||
graphql, | ||
ini, | ||
java, | ||
javascript, | ||
json, | ||
kotlin, | ||
less, | ||
lua, | ||
makefile, | ||
markdown, | ||
objectivec, | ||
perl, | ||
php, | ||
'php-template': phpTemplate, | ||
plaintext, | ||
python, | ||
'python-repl': pythonRepl, | ||
r, | ||
ruby, | ||
rust, | ||
scss, | ||
shell, | ||
sql, | ||
swift, | ||
typescript, | ||
vbnet, | ||
wasm, | ||
xml, | ||
yaml | ||
} |
@@ -1,120 +0,128 @@ | ||
export namespace lowlight { | ||
export {highlight} | ||
export {highlightAuto} | ||
export {registerLanguage} | ||
export {registered} | ||
export {listLanguages} | ||
export {registerAlias} | ||
} | ||
export type Text = import('hast').Text | ||
export type HighlightResult = import('highlight.js').HighlightResult | ||
export type HighlightOptions = import('highlight.js').HLJSOptions | ||
export type HighlightSyntax = import('highlight.js').LanguageFn | ||
export type HighlightEmitter = import('highlight.js').Emitter | ||
export type Span = { | ||
type: 'element' | ||
tagName: 'span' | ||
properties: { | ||
className: Array<string> | ||
} | ||
children: Array<Span | Text> | ||
} | ||
export type Root = { | ||
type: 'root' | ||
data: { | ||
language: string | null | ||
relevance: number | ||
} | ||
children: Array<Span | Text> | ||
} | ||
export type ExtraOptions = { | ||
/** | ||
* List of allowed languages, defaults to all registered languages. | ||
*/ | ||
subset?: Array<string> | ||
} | ||
/** | ||
* Configuration. | ||
*/ | ||
export type Options = { | ||
/** | ||
* Class prefix. | ||
*/ | ||
prefix?: string | ||
} | ||
export type AutoOptions = Options & ExtraOptions | ||
/** | ||
* Highlight `value` (code) as `language` (name). | ||
* Create a `lowlight` instance. | ||
* | ||
* @param {string} language | ||
* Programming language name. | ||
* @param {string} value | ||
* Code to highlight. | ||
* @param {Options} [options={}] | ||
* Configuration. | ||
* @returns {Root} | ||
* A hast `Root` node. | ||
* @param {Readonly<Record<string, LanguageFn>> | null | undefined} [grammars] | ||
* Grammars to add (optional). | ||
* @returns | ||
* Lowlight. | ||
*/ | ||
declare function highlight( | ||
language: string, | ||
value: string, | ||
options?: Options | undefined | ||
): Root | ||
export function createLowlight(grammars?: Readonly<Record<string, LanguageFn>> | null | undefined): { | ||
highlight: (language: string, value: string, options?: Readonly<Options> | null | undefined) => Root; | ||
highlightAuto: (value: string, options?: Readonly<AutoOptions> | null | undefined) => Root; | ||
listLanguages: () => Array<string>; | ||
registerAlias: { | ||
/** | ||
* Register aliases for already registered languages. | ||
* | ||
* @overload | ||
* @param {Readonly<Record<string, ReadonlyArray<string> | string>>} aliaseMap | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {string} language | ||
* @param {ReadonlyArray<string> | string} aliases | ||
* @returns {undefined} | ||
* | ||
* @param {Readonly<Record<string, ReadonlyArray<string> | string>> | string} language | ||
* Programming language name or a map of `language`s to `alias`es or `list`s | ||
* @param {ReadonlyArray<string> | string | undefined} [alias] | ||
* New aliases for the programming language. | ||
* @returns {undefined} | ||
* Nothing. | ||
*/ | ||
(aliaseMap: Readonly<Record<string, ReadonlyArray<string> | string>>): undefined; | ||
/** | ||
* Register aliases for already registered languages. | ||
* | ||
* @overload | ||
* @param {Readonly<Record<string, ReadonlyArray<string> | string>>} aliaseMap | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {string} language | ||
* @param {ReadonlyArray<string> | string} aliases | ||
* @returns {undefined} | ||
* | ||
* @param {Readonly<Record<string, ReadonlyArray<string> | string>> | string} language | ||
* Programming language name or a map of `language`s to `alias`es or `list`s | ||
* @param {ReadonlyArray<string> | string | undefined} [alias] | ||
* New aliases for the programming language. | ||
* @returns {undefined} | ||
* Nothing. | ||
*/ | ||
(language: string, aliases: ReadonlyArray<string> | string): undefined; | ||
}; | ||
registerLanguage: { | ||
/** | ||
* Register languages. | ||
* | ||
* @overload | ||
* @param {Readonly<Record<string, LanguageFn>>} languageMap | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {string} name | ||
* @param {LanguageFn} language | ||
* @returns {undefined} | ||
* | ||
* @param {Readonly<Record<string, LanguageFn>> | string} languageMapOrName | ||
* Programming language name or a map of names to language functions. | ||
* @param {LanguageFn | undefined} [languageFn] | ||
* Language function, if with name. | ||
* @returns {undefined} | ||
* Nothing. | ||
*/ | ||
(languageMap: Readonly<Record<string, LanguageFn>>): undefined; | ||
/** | ||
* Register languages. | ||
* | ||
* @overload | ||
* @param {Readonly<Record<string, LanguageFn>>} languageMap | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {string} name | ||
* @param {LanguageFn} language | ||
* @returns {undefined} | ||
* | ||
* @param {Readonly<Record<string, LanguageFn>> | string} languageMapOrName | ||
* Programming language name or a map of names to language functions. | ||
* @param {LanguageFn | undefined} [languageFn] | ||
* Language function, if with name. | ||
* @returns {undefined} | ||
* Nothing. | ||
*/ | ||
(name: string, language: LanguageFn): undefined; | ||
}; | ||
registered: (aliasOrLanguage: string) => boolean; | ||
}; | ||
export type Element = import('hast').Element; | ||
export type ElementContent = import('hast').ElementContent; | ||
export type Root = import('hast').Root; | ||
export type RootData = import('hast').RootData; | ||
export type Emitter = import('highlight.js').Emitter; | ||
export type HljsOptions = import('highlight.js').HLJSOptions; | ||
export type HighlightResult = import('highlight.js').HighlightResult; | ||
export type LanguageFn = import('highlight.js').LanguageFn; | ||
/** | ||
* Highlight `value` (code) and guess its programming language. | ||
* | ||
* @param {string} value | ||
* Code to highlight. | ||
* @param {AutoOptions} [options={}] | ||
* Configuration. | ||
* @returns {Root} | ||
* A hast `Root` node. | ||
* Extra fields. | ||
*/ | ||
declare function highlightAuto( | ||
value: string, | ||
options?: AutoOptions | undefined | ||
): Root | ||
export type ExtraOptions = { | ||
/** | ||
* List of allowed languages (default: all registered languages). | ||
*/ | ||
subset?: ReadonlyArray<string> | null | undefined; | ||
}; | ||
/** | ||
* Register a language. | ||
* | ||
* @param {string} language | ||
* Programming language name. | ||
* @param {HighlightSyntax} syntax | ||
* `highlight.js` language syntax. | ||
* @returns {void} | ||
* Configuration for `highlight`. | ||
*/ | ||
declare function registerLanguage( | ||
language: string, | ||
syntax: HighlightSyntax | ||
): void | ||
export type Options = { | ||
/** | ||
* Class prefix (default: `'hljs-'`). | ||
*/ | ||
prefix?: string | null | undefined; | ||
}; | ||
/** | ||
* Check whether an `alias` or `language` is registered. | ||
* | ||
* @param {string} aliasOrLanguage | ||
* Name of a registered language or alias. | ||
* @returns {boolean} | ||
* Whether `aliasOrlanguage` is registered. | ||
* Configuration for `highlightAuto`. | ||
*/ | ||
declare function registered(aliasOrLanguage: string): boolean | ||
/** | ||
* List registered languages. | ||
* | ||
* @returns {Array<string>} | ||
* Names of registered language. | ||
*/ | ||
declare function listLanguages(): Array<string> | ||
/** | ||
* Register aliases for already registered languages. | ||
* | ||
* @param {string|Record<string, string|Array<string>>} language | ||
* Programming language name or a map of `language`s to `alias`es or `list`s | ||
* @param {string|Array<string>} [alias] | ||
* New aliases for the programming language. | ||
* @returns {void} | ||
*/ | ||
declare const registerAlias: (( | ||
language: string, | ||
alias: string | Array<string> | ||
) => void) & | ||
((aliases: Record<string, string | Array<string>>) => void) | ||
export {} | ||
export type AutoOptions = Options & ExtraOptions; |
{ | ||
"name": "lowlight", | ||
"version": "2.9.0", | ||
"version": "3.0.0", | ||
"description": "Virtual syntax highlighting for virtual DOMs and non-HTML things", | ||
@@ -27,10 +27,5 @@ "license": "MIT", | ||
], | ||
"sideEffects": [ | ||
"index.js", | ||
"lib/all.js", | ||
"lib/common.js" | ||
], | ||
"sideEffects": false, | ||
"type": "module", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"exports": "./index.js", | ||
"files": [ | ||
@@ -42,16 +37,16 @@ "lib/", | ||
"dependencies": { | ||
"@types/hast": "^2.0.0", | ||
"fault": "^2.0.0", | ||
"@types/hast": "^3.0.0", | ||
"devlop": "^1.0.0", | ||
"highlight.js": "~11.8.0" | ||
}, | ||
"devDependencies": { | ||
"@types/mdast": "^3.0.0", | ||
"@types/mdast": "^4.0.0", | ||
"@types/node": "^20.0.0", | ||
"@types/unist": "^2.0.0", | ||
"c8": "^7.0.0", | ||
"@types/unist": "^3.0.0", | ||
"c8": "^8.0.0", | ||
"chalk": "^5.0.0", | ||
"estree-util-is-identifier-name": "^2.0.0", | ||
"mdast-zone": "^5.0.0", | ||
"prettier": "^2.0.0", | ||
"rehype": "^12.0.0", | ||
"estree-util-is-identifier-name": "^3.0.0", | ||
"hast-util-to-html": "^9.0.0", | ||
"mdast-zone": "^6.0.0", | ||
"prettier": "^3.0.0", | ||
"remark-cli": "^11.0.0", | ||
@@ -61,33 +56,25 @@ "remark-preset-wooorm": "^9.0.0", | ||
"typescript": "^5.0.0", | ||
"unist-builder": "^3.0.0", | ||
"unist-util-remove-position": "^4.0.0", | ||
"xo": "^0.54.0" | ||
"unified": "^11.0.0", | ||
"xo": "^0.56.0" | ||
}, | ||
"scripts": { | ||
"build": "tsc --build --clean && tsc --build && type-coverage", | ||
"format": "remark . --frail --output --quiet && prettier . --log-level warn --write && xo --fix", | ||
"generate": "node --conditions development script/build-registry.js", | ||
"prepack": "npm run generate && npm run build && npm run format", | ||
"generate": "node --conditions development script/build-registry.js", | ||
"build": "tsc --build --clean && tsc --build && type-coverage", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"test": "npm run generate && npm run build && npm run format && npm run test-coverage", | ||
"test-api": "node --conditions development test/index.js", | ||
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api", | ||
"test": "npm run generate && npm run build && npm run format && npm run test-coverage" | ||
"test-coverage": "c8 --100 --check-coverage --reporter lcov npm run test-api" | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"bracketSpacing": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"semi": false, | ||
"trailingComma": "none" | ||
"tabWidth": 2, | ||
"trailingComma": "none", | ||
"useTabs": false | ||
}, | ||
"xo": { | ||
"prettier": true, | ||
"rules": { | ||
"n/file-extension-in-import": "off" | ||
} | ||
}, | ||
"remarkConfig": { | ||
"plugins": [ | ||
"preset-wooorm", | ||
"./script/count.js", | ||
"remark-preset-wooorm", | ||
"./script/support.js" | ||
@@ -99,8 +86,33 @@ ] | ||
"detail": true, | ||
"strict": true, | ||
"ignoreCatch": true, | ||
"ignoreFiles": [ | ||
"lib/common.d.ts" | ||
] | ||
"strict": true | ||
}, | ||
"xo": { | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"**/*.ts" | ||
], | ||
"rules": { | ||
"@typescript-eslint/consistent-type-definitions": "off" | ||
} | ||
}, | ||
{ | ||
"files": [ | ||
"script/**/*.js", | ||
"test/**/*.js" | ||
], | ||
"rules": { | ||
"no-await-in-loop": "off" | ||
} | ||
} | ||
], | ||
"prettier": true, | ||
"rules": { | ||
"n/file-extension-in-import": "off", | ||
"unicorn/no-this-assignment": "off", | ||
"unicorn/prefer-at": "off", | ||
"unicorn/prefer-type-error": "off" | ||
} | ||
} | ||
} |
356
readme.md
@@ -10,3 +10,4 @@ <!--lint disable no-html--> | ||
Virtual syntax highlighting for virtual DOMs and non-HTML things. | ||
Virtual syntax highlighting for virtual DOMs and non-HTML things based on | ||
[`highlight.js`][highlight-js]. | ||
@@ -20,11 +21,17 @@ ## Contents | ||
* [API](#api) | ||
* [`all`](#all) | ||
* [`common`](#common) | ||
* [`createLowlight([grammars])`](#createlowlightgrammars) | ||
* [`lowlight.highlight(language, value[, options])`](#lowlighthighlightlanguage-value-options) | ||
* [`lowlight.highlightAuto(value[, options])`](#lowlighthighlightautovalue-options) | ||
* [`lowlight.registerLanguage(language, syntax)`](#lowlightregisterlanguagelanguage-syntax) | ||
* [`lowlight.registerAlias(language, alias)`](#lowlightregisteraliaslanguage-alias) | ||
* [`lowlight.listLanguages()`](#lowlightlistlanguages) | ||
* [`lowlight.register(grammars)`](#lowlightregistergrammars) | ||
* [`lowlight.registerAlias(aliases)`](#lowlightregisteraliasaliases) | ||
* [`lowlight.registered(aliasOrlanguage)`](#lowlightregisteredaliasorlanguage) | ||
* [`lowlight.listLanguages()`](#lowlightlistlanguages) | ||
* [`AutoOptions`](#autooptions) | ||
* [`LanguageFn`](#languagefn) | ||
* [`Options`](#options) | ||
* [Examples](#examples) | ||
* [Example: serializing hast as html](#example-serializing-hast-as-html) | ||
* [Example: turning hast into react nodes](#example-turning-hast-into-react-nodes) | ||
* [Example: turning hast into preact, react, etc](#example-turning-hast-into-preact-react-etc) | ||
* [Types](#types) | ||
@@ -42,19 +49,6 @@ * [Data](#data) | ||
This package wraps [highlight.js][] to output objects (ASTs) instead of a string | ||
of HTML. | ||
This package uses [`highlight.js`][highlight-js] for syntax highlighting and | ||
outputs objects (ASTs) instead of a string of HTML. | ||
It can support 190+ programming languages. | ||
`highlight.js`, through lowlight, supports 190+ programming languages. | ||
Supporting all of them requires a lot of code. | ||
That’s why there are three entry points for lowlight: | ||
<!--index start--> | ||
* `lib/core.js` — 0 languages | ||
* `lib/common.js` (default) — 37 languages | ||
* `lib/all.js` — 192 languages | ||
<!--index end--> | ||
Bundled, minified, and gzipped, those are roughly 9.7 kB, 47 kB, and 290 kB. | ||
## When should I use this? | ||
@@ -69,5 +63,5 @@ | ||
A different package, [`refractor`][refractor], does the same as lowlight but | ||
uses [Prism][] instead. | ||
If you’re looking for a *really good* (but rather heavy) highlighter, try | ||
You can use the similar [`refractor`][refractor] if you want to use [Prism][] | ||
grammars instead. | ||
If you’re looking for a *really good* (but rather heavy) alternative, use | ||
[`starry-night`][starry-night]. | ||
@@ -78,3 +72,3 @@ | ||
This package is [ESM only][esm]. | ||
In Node.js (version 14.14+, 16.0+), install with [npm][]: | ||
In Node.js (version 16+), install with [npm][]: | ||
@@ -88,3 +82,3 @@ ```sh | ||
```js | ||
import {lowlight} from 'https://esm.sh/lowlight@2' | ||
import {all, common, createLowlight} from 'https://esm.sh/lowlight@3' | ||
``` | ||
@@ -96,3 +90,3 @@ | ||
<script type="module"> | ||
import {lowlight} from 'https://esm.sh/lowlight@2?bundle' | ||
import {all, common, createLowlight} from 'https://esm.sh/lowlight@3?bundle' | ||
</script> | ||
@@ -104,7 +98,9 @@ ``` | ||
```js | ||
import {lowlight} from 'lowlight' | ||
import {common, createLowlight} from 'lowlight' | ||
const lowlight = createLowlight(common) | ||
const tree = lowlight.highlight('js', '"use strict";') | ||
console.dir(tree, {depth: null}) | ||
console.dir(tree, {depth: undefined}) | ||
``` | ||
@@ -117,3 +113,2 @@ | ||
type: 'root', | ||
data: {language: 'js', relevance: 10}, | ||
children: [ | ||
@@ -127,3 +122,4 @@ { | ||
{type: 'text', value: ';'} | ||
] | ||
], | ||
data: {language: 'js', relevance: 10} | ||
} | ||
@@ -134,5 +130,28 @@ ``` | ||
This package exports the identifier `lowlight`. | ||
This package exports the identifiers [`all`][api-all], | ||
[`common`][api-common], and | ||
[`createLowlight`][api-create-lowlight]. | ||
There is no default export. | ||
### `all` | ||
Map of all (±190) grammars ([`Record<string, LanguageFn>`][api-language-fn]). | ||
### `common` | ||
Map of common (37) grammars ([`Record<string, LanguageFn>`][api-language-fn]). | ||
### `createLowlight([grammars])` | ||
Create a `lowlight` instance. | ||
###### Parameters | ||
* `grammars` ([`Record<string, LanguageFn>`][api-language-fn], optional) | ||
— grammars to add | ||
###### Returns | ||
Lowlight (`Lowlight`). | ||
### `lowlight.highlight(language, value[, options])` | ||
@@ -148,19 +167,18 @@ | ||
— code to highlight | ||
* `options.prefix` (`string?`, default: `'hljs-'`) | ||
— class prefix | ||
* `options` ([`Options`][api-options], optional) | ||
— configuration | ||
###### Returns | ||
A hast [`Root`][root] node with the following `data` fields: | ||
Tree ([`Root`][hast-root]); with the following `data` fields: `language` | ||
(`string`), detected programming language name; `relevance` (`number`), how | ||
sure lowlight is that the given code is in the language. | ||
* `relevance` (`number`) | ||
— how sure lowlight is that the given code is in the language | ||
* `language` (`string`) | ||
— detected programming language name | ||
###### Example | ||
```js | ||
import {lowlight} from 'lowlight' | ||
import {common, createLowlight} from 'lowlight' | ||
const lowlight = createLowlight(common) | ||
console.log(lowlight.highlight('css', 'em { color: red }')) | ||
@@ -172,3 +190,3 @@ ``` | ||
```js | ||
{type: 'root', data: {language: 'css', relevance: 3}, children: [Array]} | ||
{type: 'root', children: [Array], data: {language: 'css', relevance: 3}} | ||
``` | ||
@@ -184,10 +202,10 @@ | ||
— code to highlight | ||
* `options.prefix` (`string?`, default: `'hljs-'`) | ||
— class prefix | ||
* `options.subset` (`Array<string>`, default: all registered language names) | ||
— list of allowed languages | ||
* `options` ([`AutoOptions`][api-auto-options], optional) | ||
— configuration | ||
###### Returns | ||
The same result as `lowlight.highlight` is returned. | ||
Tree ([`Root`][hast-root]); with the following `data` fields: `language` | ||
(`string`), detected programming language name; `relevance` (`number`), how | ||
sure lowlight is that the given code is in the language. | ||
@@ -197,4 +215,6 @@ ###### Example | ||
```js | ||
import {lowlight} from 'lowlight' | ||
import {common, createLowlight} from 'lowlight' | ||
const lowlight = createLowlight(common) | ||
console.log(lowlight.highlightAuto('"hello, " + name + "!"')) | ||
@@ -206,21 +226,49 @@ ``` | ||
```js | ||
{type: 'root', data: {language: 'applescript', relevance: 3}, children: [Array]} | ||
{type: 'root', children: [Array], data: {language: 'arduino', relevance: 2}} | ||
``` | ||
### `lowlight.listLanguages()` | ||
List registered languages. | ||
###### Returns | ||
[Names][] of registered language (`Array<string>`). | ||
###### Example | ||
```js | ||
import {createLowlight} from 'lowlight' | ||
import markdown from 'highlight.js/lib/languages/markdown' | ||
const lowlight = createLowlight() | ||
console.log(lowlight.listLanguages()) // => [] | ||
lowlight.register({markdown}) | ||
console.log(lowlight.listLanguages()) // => ['markdown'] | ||
``` | ||
### `lowlight.registerLanguage(language, syntax)` | ||
### `lowlight.register(grammars)` | ||
Register a language. | ||
Register languages. | ||
###### Signatures | ||
* `register(name, grammar)` | ||
* `register(grammars)` | ||
###### Parameters | ||
* `language` (`string`) | ||
— programming language name | ||
* `syntax` ([`HighlightSyntax`][syntax]) | ||
— `highlight.js` syntax | ||
* `name` (`string`) | ||
— programming language [name][names] | ||
* `grammar` ([`LanguageFn`][api-language-fn]) | ||
— grammar | ||
* `grammars` ([`Record<string, LanguageFn>`][api-language-fn], optional) | ||
— grammars | ||
###### Note | ||
###### Returns | ||
`highlight.js` operates as a singleton: once you register a language in one | ||
place, it’ll be available everywhere. | ||
Nothing (`undefined`). | ||
@@ -230,7 +278,10 @@ ###### Example | ||
```js | ||
import {lowlight} from 'lowlight/lib/core.js' | ||
import xml from 'highlight.js/lib/languages/xml.js' | ||
import {createLowlight} from 'lowlight' | ||
import xml from 'highlight.js/lib/languages/xml' | ||
lowlight.registerLanguage('xml', xml) | ||
const lowlight = createLowlight() | ||
lowlight.register({xml}) | ||
// Note: `html` is an alias for `xml`. | ||
console.log(lowlight.highlight('html', '<em>Emphasis</em>')) | ||
@@ -242,33 +293,37 @@ ``` | ||
```js | ||
{type: 'root', data: {language: 'html', relevance: 2}, children: [Array]} | ||
{type: 'root', children: [Array], data: {language: 'html', relevance: 2}} | ||
``` | ||
### `lowlight.registerAlias(language, alias)` | ||
### `lowlight.registerAlias(aliases)` | ||
Register aliases for already registered languages. | ||
Register aliases. | ||
###### Signatures | ||
* `registerAlias(language, alias|list)` | ||
* `registerAlias(aliases)` | ||
* `registerAlias(name, alias)` | ||
###### Parameters | ||
* `language` (`string`) | ||
* `aliases` (`Record<string, Array<string> | string>`) | ||
— map of programming language [names][] to one or more aliases | ||
* `name` (`string`) | ||
— programming language [name][names] | ||
* `alias` (`string`) | ||
— new aliases for the programming language | ||
* `list` (`Array<string>`) | ||
— list of aliases | ||
* `aliases` (`Record<language, alias|list>`) | ||
— map of `language`s to `alias`es or `list`s | ||
* `alias` (`Array<string> | string`) | ||
— one or more aliases for the programming language | ||
###### Returns | ||
Nothing (`undefined`). | ||
###### Example | ||
```js | ||
import {lowlight} from 'lowlight/lib/core.js' | ||
import md from 'highlight.js/lib/languages/markdown.js' | ||
import {createLowlight} from 'lowlight' | ||
import markdown from 'highlight.js/lib/languages/markdown' | ||
lowlight.registerLanguage('markdown', md) | ||
const lowlight = createLowlight() | ||
lowlight.register({markdown}) | ||
// lowlight.highlight('mdown', '<em>Emphasis</em>') | ||
@@ -284,3 +339,3 @@ // ^ would throw: Error: Unknown language: `mdown` is not registered | ||
Check whether an `alias` or `language` is registered. | ||
Check whether an alias or name is registered. | ||
@@ -290,7 +345,7 @@ ###### Parameters | ||
* `aliasOrlanguage` (`string`) | ||
— [name][names] of a registered language or alias | ||
— [name][names] of a language or alias for one | ||
###### Returns | ||
Whether `aliasOrlanguage` is registered (`boolean`). | ||
Whether `aliasOrName` is registered (`boolean`). | ||
@@ -300,34 +355,43 @@ ###### Example | ||
```js | ||
import {lowlight} from 'lowlight/lib/core.js' | ||
import javascript from 'highlight.js/lib/languages/javascript.js' | ||
import {createLowlight} from 'lowlight' | ||
import javascript from 'highlight.js/lib/languages/javascript' | ||
lowlight.registerLanguage('javascript', javascript) | ||
const lowlight = createLowlight({javascript}) | ||
lowlight.registered('js') // return false | ||
console.log(lowlight.registered('funkyscript')) // => `false` | ||
lowlight.registerAlias('javascript', 'js') | ||
lowlight.registered('js') // return true | ||
lowlight.registerAlias({javascript: 'funkyscript'}) | ||
console.log(lowlight.registered('funkyscript')) // => `true` | ||
``` | ||
### `lowlight.listLanguages()` | ||
### `AutoOptions` | ||
List registered languages. | ||
Configuration for `highlightAuto` (TypeScript type). | ||
###### Returns | ||
###### Fields | ||
Names of registered language (`Array<string>`). | ||
* `prefix` (`string`, default: `'hljs-'`) | ||
— class prefix | ||
* `subset` (`Array<string>`, default: all registered languages) | ||
— list of allowed languages | ||
###### Example | ||
### `LanguageFn` | ||
```js | ||
import {lowlight} from 'lowlight/lib/core.js' | ||
import md from 'highlight.js/lib/languages/markdown.js' | ||
Highlight.js grammar (TypeScript type). | ||
console.log(lowlight.listLanguages()) // => [] | ||
###### Type | ||
lowlight.registerLanguage('markdown', md) | ||
console.log(lowlight.listLanguages()) // => ['markdown'] | ||
```ts | ||
type {LanguageFn} from 'highlight.js' | ||
``` | ||
### `Options` | ||
Configuration for `highlight` (TypeScript type). | ||
###### Fields | ||
* `prefix` (`string`, default: `'hljs-'`) | ||
— class prefix | ||
## Examples | ||
@@ -341,5 +405,7 @@ | ||
```js | ||
import {lowlight} from 'lowlight' | ||
import {common, createLowlight} from 'lowlight' | ||
import {toHtml} from 'hast-util-to-html' | ||
const lowlight = createLowlight(common) | ||
const tree = lowlight.highlight('js', '"use strict";') | ||
@@ -356,16 +422,19 @@ | ||
### Example: turning hast into react nodes | ||
### Example: turning hast into preact, react, etc | ||
hast trees as returned by lowlight can be turned into React (or Preact) with | ||
[`hast-to-hyperscript`][hast-to-hyperscript]: | ||
hast trees as returned by lowlight can be turned into nodes of any framework | ||
that supports JSX, such as preact, react, solid, svelte, vue, and more, with | ||
[`hast-util-to-jsx-runtime`][hast-util-to-jsx-runtime]: | ||
```js | ||
import {lowlight} from 'lowlight' | ||
import {toH} from 'hast-to-hyperscript' | ||
import React from 'react' | ||
import {toJsxRuntime} from 'hast-util-to-jsx-runtime' | ||
// @ts-expect-error: react types don’t type these. | ||
import {Fragment, jsx, jsxs} from 'react/jsx-runtime' | ||
import {common, createLowlight} from 'lowlight' | ||
const lowlight = createLowlight(common) | ||
const tree = lowlight.highlight('js', '"use strict";') | ||
const react = toH(React.createElement, tree) | ||
console.log(react) | ||
console.log(toJsxRuntime(tree, {Fragment, jsx, jsxs})) | ||
``` | ||
@@ -377,7 +446,7 @@ | ||
{ | ||
'$$typeof': Symbol(react.element), | ||
type: 'div', | ||
key: 'h-1', | ||
$$typeof: Symbol(react.element), | ||
type: Symbol(react.fragment), | ||
key: null, | ||
ref: null, | ||
props: { children: [ [Object], ';' ] }, | ||
props: {children: [[Object], ';']}, | ||
_owner: null, | ||
@@ -391,4 +460,26 @@ _store: {} | ||
This package is fully typed with [TypeScript][]. | ||
It exports the additional types `Root`, `Options`, and `AutoOptions`. | ||
It exports the additional types | ||
[`AutoOptions`][api-auto-options], | ||
[`LanguageFn`][api-language-fn], and | ||
[`Options`][api-options]. | ||
It also registers `root.data` with `@types/hast`. | ||
If you’re working with the data fields, make sure to import this package | ||
somewhere in your types, as that registers the new fields on the file. | ||
```js | ||
/** | ||
* @typedef {import('hast').Root} Root | ||
* | ||
* @typedef {import('lowlight')} | ||
*/ | ||
import {VFile} from 'vfile' | ||
/** @type {Root} */ | ||
const root = {type: 'root', children: []} | ||
console.log(root.data?.language) //=> TS now knows that this is a `string?`. | ||
``` | ||
<!--Old name of the following section:--> | ||
@@ -400,10 +491,10 @@ | ||
If you’re using `lowlight/lib/core.js`, no syntaxes are included. | ||
Checked syntaxes are included if you import `lowlight` (or explicitly | ||
`lowlight/lib/common.js`). | ||
Unchecked syntaxes are available through `lowlight/lib/all.js`. | ||
You can import `core` or `common` and manually add more languages as you please. | ||
If you’re using `createLowlight()`, no syntaxes are included yet. | ||
You can import `all` or `common` and pass them, such as with | ||
`createLowlight(all)`. | ||
Checked syntaxes are included in `common`. | ||
All syntaxes are included in `all`. | ||
`highlight.js` operates as a singleton: once you register a language in one | ||
place, it’ll be available everywhere. | ||
You can also manually import syntaxes from `highlight.js/lib/languages/xxx`, | ||
where `xxx` is the name, such as `'highlight.js/lib/languages/wasm'`. | ||
@@ -615,3 +706,3 @@ <!--support start--> | ||
```html | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/styles/github-dark.min.css"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github-dark.min.css"> | ||
``` | ||
@@ -621,6 +712,9 @@ | ||
This package is at least compatible with all maintained versions of Node.js. | ||
As of now, that is Node.js 14.14+ and 16.0+. | ||
It also works in Deno and modern browsers. | ||
This package is compatible with maintained versions of Node.js. | ||
When we cut a new major release, we drop support for unmaintained versions of | ||
Node. | ||
This means we try to keep the current release line, | ||
`lowlight@^3`, compatible with Node.js 16. | ||
## Security | ||
@@ -693,8 +787,6 @@ | ||
[root]: https://github.com/syntax-tree/hast#root | ||
[hast-root]: https://github.com/syntax-tree/hast#root | ||
[highlight.js]: https://github.com/highlightjs/highlight.js | ||
[highlight-js]: https://github.com/highlightjs/highlight.js | ||
[syntax]: https://github.com/highlightjs/highlight.js/blob/main/docs/language-guide.rst | ||
[names]: https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md | ||
@@ -712,2 +804,14 @@ | ||
[hast-to-hyperscript]: https://github.com/syntax-tree/hast-to-hyperscript | ||
[hast-util-to-jsx-runtime]: https://github.com/syntax-tree/hast-util-to-jsx-runtime | ||
[api-all]: #all | ||
[api-auto-options]: #autooptions | ||
[api-common]: #common | ||
[api-create-lowlight]: #createlowlightgrammars | ||
[api-language-fn]: #languagefn | ||
[api-options]: #options |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64259
15
12
1222
788
1
+ Addeddevlop@^1.0.0
+ Added@types/hast@3.0.4(transitive)
+ Added@types/unist@3.0.3(transitive)
+ Addeddequal@2.0.3(transitive)
+ Addeddevlop@1.1.0(transitive)
- Removedfault@^2.0.0
- Removed@types/hast@2.3.10(transitive)
- Removed@types/unist@2.0.11(transitive)
- Removedfault@2.0.1(transitive)
- Removedformat@0.2.2(transitive)
Updated@types/hast@^3.0.0