Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions shiki.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

import { getWasmInstance } from '@shikijs/core/wasm-inlined';

import cLanguage from 'shiki/langs/c.mjs';
import coffeeScriptLanguage from 'shiki/langs/coffeescript.mjs';
import cPlusPlusLanguage from 'shiki/langs/cpp.mjs';
Expand All @@ -24,7 +22,6 @@ import darkTheme from 'shiki/themes/catppuccin-mocha.mjs';
* @type {import('@shikijs/core').HighlighterCoreOptions}
*/
export default {
loadWasm: getWasmInstance,
// Only register the themes we need, to support light/dark theme
themes: [lightTheme, darkTheme],
// Only register the languages that the API docs use
Expand Down
50 changes: 39 additions & 11 deletions src/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,45 @@ export const DOC_SLUG_ENVIRONMENT = 'environment-variables-1';
// JavaScript globals types within the MDN JavaScript docs
// @see DOC_MDN_BASE_URL_JS_GLOBALS
export const DOC_TYPES_MAPPING_GLOBALS = {
...Object.fromEntries([
'AggregateError', 'Array', 'ArrayBuffer', 'DataView', 'Date', 'Error',
'EvalError', 'Function', 'Map', 'NaN', 'Object', 'Promise', 'Proxy', 'RangeError',
'ReferenceError', 'RegExp', 'Set', 'SharedArrayBuffer', 'SyntaxError', 'Symbol',
'TypeError', 'URIError', 'WeakMap', 'WeakSet',

'TypedArray',
'Float32Array', 'Float64Array',
'Int8Array', 'Int16Array', 'Int32Array',
'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array',
].map(e => [e, e])),
...Object.fromEntries(
[
'AggregateError',
'Array',
'ArrayBuffer',
'DataView',
'Date',
'Error',
'EvalError',
'Function',
'Map',
'NaN',
'Object',
'Promise',
'Proxy',
'RangeError',
'ReferenceError',
'RegExp',
'Set',
'SharedArrayBuffer',
'SyntaxError',
'Symbol',
'TypeError',
'URIError',
'WeakMap',
'WeakSet',

'TypedArray',
'Float32Array',
'Float64Array',
'Int8Array',
'Int16Array',
'Int32Array',
'Uint8Array',
'Uint8ClampedArray',
'Uint16Array',
'Uint32Array',
].map(e => [e, e])
),
bigint: 'BigInt',
'WebAssembly.Instance': 'WebAssembly/Instance',
};
Expand Down
12 changes: 7 additions & 5 deletions src/generators/legacy-html/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ html {
}

body {
font-family: Lato, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans',
Verdana, Tahoma, sans-serif;
font-family:
Lato, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Verdana,
Tahoma, sans-serif;
margin: 0;
padding: 0;
color: var(--color-text-primary);
Expand Down Expand Up @@ -137,8 +138,8 @@ code,
.pre,
span.type,
a.type {
font-family: SFMono-Regular, Menlo, Consolas, 'Liberation Mono',
'Courier New', monospace;
font-family:
SFMono-Regular, Menlo, Consolas, 'Liberation Mono', 'Courier New', monospace;
font-size: 0.9em;
}

Expand Down Expand Up @@ -1031,7 +1032,8 @@ kbd {
margin-right: 10px;
margin-top: -2px;
height: 1.5rem;
transition-property: background-color, border-color, color, box-shadow, filter;
transition-property:
background-color, border-color, color, box-shadow, filter;
transition-duration: 0.3s;
cursor: pointer;
}
Expand Down
8 changes: 6 additions & 2 deletions src/utils/highlighter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { h as createElement } from 'hastscript';
import { toString } from 'hast-util-to-string';
import { SKIP, visit } from 'unist-util-visit';

import { getSingletonHighlighterCore } from '@shikijs/core';
import { createHighlighterCoreSync } from '@shikijs/core';
import { createJavaScriptRegexEngine } from '@shikijs/engine-javascript';

import shikiConfig from '../../shiki.config.mjs';

Expand All @@ -14,7 +15,10 @@ import shikiConfig from '../../shiki.config.mjs';
const languagePrefix = 'language-';

// Creates a Singleton instance for Shiki's syntax highlighter using WASM
const shikiHighlighter = await getSingletonHighlighterCore(shikiConfig);
const shikiHighlighter = createHighlighterCoreSync({
...shikiConfig,
engine: createJavaScriptRegexEngine(),
});

// Creates a static button element which is used for the "copy" button
// within codeboxes for copying the code to the clipboard
Expand Down
Loading