Skip to content

Commit

Permalink
tools: import only highlight.js core
Browse files Browse the repository at this point in the history
Importing everything from highlight.js won't work in without-intl
builds. Import only core, as the code is already written to load
individual languages as needed.

Fixes: #41077
  • Loading branch information
Trott committed Dec 4, 2021
1 parent c802c4b commit 342e449
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tools/doc/html.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
import fs from 'fs';
import path from 'path';

import highlightJs from 'highlight.js';
import highlightJs from 'highlight.js/lib/core';
import c from 'highlight.js/lib/languages/c';
import coffeescript from 'highlight.js/lib/languages/coffeescript';
import cpp from 'highlight.js/lib/languages/cpp';
import http from 'highlight.js/lib/languages/http';
import javascript from 'highlight.js/lib/languages/javascript';
import json from 'highlight.js/lib/languages/json';

import raw from 'rehype-raw';
import htmlStringify from 'rehype-stringify';
import gfm from 'remark-gfm';
Expand All @@ -34,6 +41,13 @@ import { visit } from 'unist-util-visit';
import * as common from './common.mjs';
import * as typeParser from './type-parser.mjs';

highlightJs.registerLanguage('js', javascript);
highlightJs.registerLanguage('c', c);
highlightJs.registerLanguage('coffee', coffeescript);
highlightJs.registerLanguage('cpp', cpp);
highlightJs.registerLanguage('http', http);
highlightJs.registerLanguage('json', json);

const { highlight, getLanguage } = highlightJs;

const docPath = new URL('../../doc/', import.meta.url);
Expand Down

0 comments on commit 342e449

Please sign in to comment.