[ci] format
This commit is contained in:
parent
9f80a4046f
commit
991d629832
6 changed files with 2063 additions and 1630 deletions
|
@ -58,7 +58,7 @@ const highlighter = await getHighlighter({
|
||||||
});
|
});
|
||||||
const _html = highlighter.codeToHtml(code, {
|
const _html = highlighter.codeToHtml(code, {
|
||||||
lang: typeof lang === 'string' ? lang : lang.id,
|
lang: typeof lang === 'string' ? lang : lang.id,
|
||||||
theme
|
theme,
|
||||||
});
|
});
|
||||||
const html = repairShikiTheme(_html);
|
const html = repairShikiTheme(_html);
|
||||||
---
|
---
|
||||||
|
|
|
@ -19,16 +19,18 @@ function stringify(opts) {
|
||||||
*/
|
*/
|
||||||
async function resolveHighlighter(opts) {
|
async function resolveHighlighter(opts) {
|
||||||
const resolvedThemes = [];
|
const resolvedThemes = [];
|
||||||
if(opts.theme && (opts.theme in themes)) {
|
if (opts.theme && opts.theme in themes) {
|
||||||
resolvedThemes.push(await themes[opts.theme]());
|
resolvedThemes.push(await themes[opts.theme]());
|
||||||
}
|
}
|
||||||
|
|
||||||
let resolvedLanguages;
|
let resolvedLanguages;
|
||||||
if(opts.langs) {
|
if (opts.langs) {
|
||||||
resolvedLanguages = opts.langs;
|
resolvedLanguages = opts.langs;
|
||||||
} else {
|
} else {
|
||||||
if(!_allLanguages) {
|
if (!_allLanguages) {
|
||||||
_allLanguages = (await Promise.all(Object.values(languages).map(fn => fn()))).filter(Boolean);
|
_allLanguages = (await Promise.all(Object.values(languages).map((fn) => fn()))).filter(
|
||||||
|
Boolean
|
||||||
|
);
|
||||||
}
|
}
|
||||||
resolvedLanguages = await _allLanguages;
|
resolvedLanguages = await _allLanguages;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +39,7 @@ async function resolveHighlighter(opts) {
|
||||||
const highlighterOptions = {
|
const highlighterOptions = {
|
||||||
...opts,
|
...opts,
|
||||||
themes: resolvedThemes,
|
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
|
// 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
|
@ -1,31 +1,33 @@
|
||||||
export const themes = {
|
export const themes = {
|
||||||
'css-variables': () => import('shiki/themes/css-variables.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),
|
'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-soft': () => import('shiki/themes/dracula-soft.json').then((mod) => mod.default),
|
||||||
'dracula': () => import('shiki/themes/dracula.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-dimmed': () =>
|
||||||
'github-dark': () => import('shiki/themes/github-dark.json').then(mod => mod.default),
|
import('shiki/themes/github-dark-dimmed.json').then((mod) => mod.default),
|
||||||
'github-light': () => import('shiki/themes/github-light.json').then(mod => mod.default),
|
'github-dark': () => import('shiki/themes/github-dark.json').then((mod) => mod.default),
|
||||||
'hc_light': () => import('shiki/themes/hc_light.json').then(mod => mod.default),
|
'github-light': () => import('shiki/themes/github-light.json').then((mod) => mod.default),
|
||||||
'light-plus': () => import('shiki/themes/light-plus.json').then(mod => mod.default),
|
hc_light: () => import('shiki/themes/hc_light.json').then((mod) => mod.default),
|
||||||
'material-darker': () => import('shiki/themes/material-darker.json').then(mod => mod.default),
|
'light-plus': () => import('shiki/themes/light-plus.json').then((mod) => mod.default),
|
||||||
'material-default': () => import('shiki/themes/material-default.json').then(mod => mod.default),
|
'material-darker': () => import('shiki/themes/material-darker.json').then((mod) => mod.default),
|
||||||
'material-lighter': () => import('shiki/themes/material-lighter.json').then(mod => mod.default),
|
'material-default': () => import('shiki/themes/material-default.json').then((mod) => mod.default),
|
||||||
'material-ocean': () => import('shiki/themes/material-ocean.json').then(mod => mod.default),
|
'material-lighter': () => import('shiki/themes/material-lighter.json').then((mod) => mod.default),
|
||||||
'material-palenight': () => import('shiki/themes/material-palenight.json').then(mod => mod.default),
|
'material-ocean': () => import('shiki/themes/material-ocean.json').then((mod) => mod.default),
|
||||||
'min-dark': () => import('shiki/themes/min-dark.json').then(mod => mod.default),
|
'material-palenight': () =>
|
||||||
'min-light': () => import('shiki/themes/min-light.json').then(mod => mod.default),
|
import('shiki/themes/material-palenight.json').then((mod) => mod.default),
|
||||||
'monokai': () => import('shiki/themes/monokai.json').then(mod => mod.default),
|
'min-dark': () => import('shiki/themes/min-dark.json').then((mod) => mod.default),
|
||||||
'nord': () => import('shiki/themes/nord.json').then(mod => mod.default),
|
'min-light': () => import('shiki/themes/min-light.json').then((mod) => mod.default),
|
||||||
'one-dark-pro': () => import('shiki/themes/one-dark-pro.json').then(mod => mod.default),
|
monokai: () => import('shiki/themes/monokai.json').then((mod) => mod.default),
|
||||||
'poimandres': () => import('shiki/themes/poimandres.json').then(mod => mod.default),
|
nord: () => import('shiki/themes/nord.json').then((mod) => mod.default),
|
||||||
'rose-pine-dawn': () => import('shiki/themes/rose-pine-dawn.json').then(mod => mod.default),
|
'one-dark-pro': () => import('shiki/themes/one-dark-pro.json').then((mod) => mod.default),
|
||||||
'rose-pine-moon': () => import('shiki/themes/rose-pine-moon.json').then(mod => mod.default),
|
poimandres: () => import('shiki/themes/poimandres.json').then((mod) => mod.default),
|
||||||
'rose-pine': () => import('shiki/themes/rose-pine.json').then(mod => mod.default),
|
'rose-pine-dawn': () => import('shiki/themes/rose-pine-dawn.json').then((mod) => mod.default),
|
||||||
'slack-dark': () => import('shiki/themes/slack-dark.json').then(mod => mod.default),
|
'rose-pine-moon': () => import('shiki/themes/rose-pine-moon.json').then((mod) => mod.default),
|
||||||
'slack-ochin': () => import('shiki/themes/slack-ochin.json').then(mod => mod.default),
|
'rose-pine': () => import('shiki/themes/rose-pine.json').then((mod) => mod.default),
|
||||||
'solarized-dark': () => import('shiki/themes/solarized-dark.json').then(mod => mod.default),
|
'slack-dark': () => import('shiki/themes/slack-dark.json').then((mod) => mod.default),
|
||||||
'solarized-light': () => import('shiki/themes/solarized-light.json').then(mod => mod.default),
|
'slack-ochin': () => import('shiki/themes/slack-ochin.json').then((mod) => mod.default),
|
||||||
'vitesse-dark': () => import('shiki/themes/vitesse-dark.json').then(mod => mod.default),
|
'solarized-dark': () => import('shiki/themes/solarized-dark.json').then((mod) => mod.default),
|
||||||
'vitesse-light': () => import('shiki/themes/vitesse-light.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),
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ import fs from 'fs';
|
||||||
|
|
||||||
const dir = await fs.promises.readdir('packages/astro/node_modules/shiki/languages/');
|
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'));
|
const key = f.slice(0, f.indexOf('.tmLanguage.json'));
|
||||||
return [
|
return [
|
||||||
key,
|
key,
|
||||||
|
@ -16,15 +16,15 @@ const langImports = dir.map(f => {
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
})`
|
})`,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
let code = `import { BUNDLED_LANGUAGES } from 'shiki';
|
let code = `import { BUNDLED_LANGUAGES } from 'shiki';
|
||||||
|
|
||||||
export const languages = {`;
|
export const languages = {`;
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for(const [key, imp] of langImports) {
|
for (const [key, imp] of langImports) {
|
||||||
if(i > 0) {
|
if (i > 0) {
|
||||||
code += ',';
|
code += ',';
|
||||||
}
|
}
|
||||||
code += `\n\t'${key}': () => ${imp}`;
|
code += `\n\t'${key}': () => ${imp}`;
|
||||||
|
|
|
@ -2,17 +2,14 @@ import fs from 'fs';
|
||||||
|
|
||||||
const dir = await fs.promises.readdir('packages/astro/node_modules/shiki/themes/');
|
const dir = await fs.promises.readdir('packages/astro/node_modules/shiki/themes/');
|
||||||
|
|
||||||
const themeImports = dir.map(f => {
|
const themeImports = dir.map((f) => {
|
||||||
return [
|
return [f.slice(0, f.indexOf('.json')), `import('shiki/themes/${f}').then(mod => mod.default)`];
|
||||||
f.slice(0, f.indexOf('.json')),
|
|
||||||
`import('shiki/themes/${f}').then(mod => mod.default)`
|
|
||||||
];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let code = `export const themes = {`;
|
let code = `export const themes = {`;
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for(const [key, imp] of themeImports) {
|
for (const [key, imp] of themeImports) {
|
||||||
if(i > 0) {
|
if (i > 0) {
|
||||||
code += ',';
|
code += ',';
|
||||||
}
|
}
|
||||||
code += `\n\t'${key}': () => ${imp}`;
|
code += `\n\t'${key}': () => ${imp}`;
|
||||||
|
|
Loading…
Reference in a new issue