[ci] format

This commit is contained in:
matthewp 2022-11-16 13:59:51 +00:00 committed by fredkbot
parent 9f80a4046f
commit 991d629832
6 changed files with 2063 additions and 1630 deletions

View file

@ -58,7 +58,7 @@ const highlighter = await getHighlighter({
});
const _html = highlighter.codeToHtml(code, {
lang: typeof lang === 'string' ? lang : lang.id,
theme
theme,
});
const html = repairShikiTheme(_html);
---

View file

@ -19,16 +19,18 @@ function stringify(opts) {
*/
async function resolveHighlighter(opts) {
const resolvedThemes = [];
if(opts.theme && (opts.theme in themes)) {
if (opts.theme && opts.theme in themes) {
resolvedThemes.push(await themes[opts.theme]());
}
let resolvedLanguages;
if(opts.langs) {
if (opts.langs) {
resolvedLanguages = opts.langs;
} else {
if(!_allLanguages) {
_allLanguages = (await Promise.all(Object.values(languages).map(fn => fn()))).filter(Boolean);
if (!_allLanguages) {
_allLanguages = (await Promise.all(Object.values(languages).map((fn) => fn()))).filter(
Boolean
);
}
resolvedLanguages = await _allLanguages;
}
@ -37,7 +39,7 @@ async function resolveHighlighter(opts) {
const highlighterOptions = {
...opts,
themes: resolvedThemes,
langs: resolvedLanguages
langs: resolvedLanguages,
};
// Do not pass through the theme as that will attempt to load it, even if it's included in themes

File diff suppressed because it is too large Load diff

View file

@ -1,31 +1,33 @@
export const themes = {
'css-variables': () => import('shiki/themes/css-variables.json').then(mod => mod.default),
'dark-plus': () => import('shiki/themes/dark-plus.json').then(mod => mod.default),
'dracula-soft': () => import('shiki/themes/dracula-soft.json').then(mod => mod.default),
'dracula': () => import('shiki/themes/dracula.json').then(mod => mod.default),
'github-dark-dimmed': () => import('shiki/themes/github-dark-dimmed.json').then(mod => mod.default),
'github-dark': () => import('shiki/themes/github-dark.json').then(mod => mod.default),
'github-light': () => import('shiki/themes/github-light.json').then(mod => mod.default),
'hc_light': () => import('shiki/themes/hc_light.json').then(mod => mod.default),
'light-plus': () => import('shiki/themes/light-plus.json').then(mod => mod.default),
'material-darker': () => import('shiki/themes/material-darker.json').then(mod => mod.default),
'material-default': () => import('shiki/themes/material-default.json').then(mod => mod.default),
'material-lighter': () => import('shiki/themes/material-lighter.json').then(mod => mod.default),
'material-ocean': () => import('shiki/themes/material-ocean.json').then(mod => mod.default),
'material-palenight': () => import('shiki/themes/material-palenight.json').then(mod => mod.default),
'min-dark': () => import('shiki/themes/min-dark.json').then(mod => mod.default),
'min-light': () => import('shiki/themes/min-light.json').then(mod => mod.default),
'monokai': () => import('shiki/themes/monokai.json').then(mod => mod.default),
'nord': () => import('shiki/themes/nord.json').then(mod => mod.default),
'one-dark-pro': () => import('shiki/themes/one-dark-pro.json').then(mod => mod.default),
'poimandres': () => import('shiki/themes/poimandres.json').then(mod => mod.default),
'rose-pine-dawn': () => import('shiki/themes/rose-pine-dawn.json').then(mod => mod.default),
'rose-pine-moon': () => import('shiki/themes/rose-pine-moon.json').then(mod => mod.default),
'rose-pine': () => import('shiki/themes/rose-pine.json').then(mod => mod.default),
'slack-dark': () => import('shiki/themes/slack-dark.json').then(mod => mod.default),
'slack-ochin': () => import('shiki/themes/slack-ochin.json').then(mod => mod.default),
'solarized-dark': () => import('shiki/themes/solarized-dark.json').then(mod => mod.default),
'solarized-light': () => import('shiki/themes/solarized-light.json').then(mod => mod.default),
'vitesse-dark': () => import('shiki/themes/vitesse-dark.json').then(mod => mod.default),
'vitesse-light': () => import('shiki/themes/vitesse-light.json').then(mod => mod.default)
'css-variables': () => import('shiki/themes/css-variables.json').then((mod) => mod.default),
'dark-plus': () => import('shiki/themes/dark-plus.json').then((mod) => mod.default),
'dracula-soft': () => import('shiki/themes/dracula-soft.json').then((mod) => mod.default),
dracula: () => import('shiki/themes/dracula.json').then((mod) => mod.default),
'github-dark-dimmed': () =>
import('shiki/themes/github-dark-dimmed.json').then((mod) => mod.default),
'github-dark': () => import('shiki/themes/github-dark.json').then((mod) => mod.default),
'github-light': () => import('shiki/themes/github-light.json').then((mod) => mod.default),
hc_light: () => import('shiki/themes/hc_light.json').then((mod) => mod.default),
'light-plus': () => import('shiki/themes/light-plus.json').then((mod) => mod.default),
'material-darker': () => import('shiki/themes/material-darker.json').then((mod) => mod.default),
'material-default': () => import('shiki/themes/material-default.json').then((mod) => mod.default),
'material-lighter': () => import('shiki/themes/material-lighter.json').then((mod) => mod.default),
'material-ocean': () => import('shiki/themes/material-ocean.json').then((mod) => mod.default),
'material-palenight': () =>
import('shiki/themes/material-palenight.json').then((mod) => mod.default),
'min-dark': () => import('shiki/themes/min-dark.json').then((mod) => mod.default),
'min-light': () => import('shiki/themes/min-light.json').then((mod) => mod.default),
monokai: () => import('shiki/themes/monokai.json').then((mod) => mod.default),
nord: () => import('shiki/themes/nord.json').then((mod) => mod.default),
'one-dark-pro': () => import('shiki/themes/one-dark-pro.json').then((mod) => mod.default),
poimandres: () => import('shiki/themes/poimandres.json').then((mod) => mod.default),
'rose-pine-dawn': () => import('shiki/themes/rose-pine-dawn.json').then((mod) => mod.default),
'rose-pine-moon': () => import('shiki/themes/rose-pine-moon.json').then((mod) => mod.default),
'rose-pine': () => import('shiki/themes/rose-pine.json').then((mod) => mod.default),
'slack-dark': () => import('shiki/themes/slack-dark.json').then((mod) => mod.default),
'slack-ochin': () => import('shiki/themes/slack-ochin.json').then((mod) => mod.default),
'solarized-dark': () => import('shiki/themes/solarized-dark.json').then((mod) => mod.default),
'solarized-light': () => import('shiki/themes/solarized-light.json').then((mod) => mod.default),
'vitesse-dark': () => import('shiki/themes/vitesse-dark.json').then((mod) => mod.default),
'vitesse-light': () => import('shiki/themes/vitesse-light.json').then((mod) => mod.default),
};

View file

@ -2,7 +2,7 @@ import fs from 'fs';
const dir = await fs.promises.readdir('packages/astro/node_modules/shiki/languages/');
const langImports = dir.map(f => {
const langImports = dir.map((f) => {
const key = f.slice(0, f.indexOf('.tmLanguage.json'));
return [
key,
@ -16,15 +16,15 @@ const langImports = dir.map(f => {
} else {
return undefined;
}
})`
})`,
];
});
let code = `import { BUNDLED_LANGUAGES } from 'shiki';
export const languages = {`;
let i = 0;
for(const [key, imp] of langImports) {
if(i > 0) {
for (const [key, imp] of langImports) {
if (i > 0) {
code += ',';
}
code += `\n\t'${key}': () => ${imp}`;

View file

@ -2,17 +2,14 @@ import fs from 'fs';
const dir = await fs.promises.readdir('packages/astro/node_modules/shiki/themes/');
const themeImports = dir.map(f => {
return [
f.slice(0, f.indexOf('.json')),
`import('shiki/themes/${f}').then(mod => mod.default)`
];
const themeImports = dir.map((f) => {
return [f.slice(0, f.indexOf('.json')), `import('shiki/themes/${f}').then(mod => mod.default)`];
});
let code = `export const themes = {`;
let i = 0;
for(const [key, imp] of themeImports) {
if(i > 0) {
for (const [key, imp] of themeImports) {
if (i > 0) {
code += ',';
}
code += `\n\t'${key}': () => ${imp}`;