[ci] format

This commit is contained in:
bholmesdev 2022-07-21 20:46:16 +00:00 committed by fredkbot
parent 3b8a744524
commit c2968b0542
3 changed files with 23 additions and 25 deletions

View file

@ -1,13 +1,13 @@
import type { RemarkMdxFrontmatterOptions } from 'remark-mdx-frontmatter';
import type { AstroIntegration } from 'astro';
import remarkShikiTwoslash from 'remark-shiki-twoslash';
import { nodeTypes } from '@mdx-js/mdx';
import rehypeRaw from 'rehype-raw';
import mdxPlugin, { Options as MdxRollupPluginOptions } from '@mdx-js/rollup';
import type { AstroIntegration } from 'astro';
import { parse as parseESM } from 'es-module-lexer';
import rehypeRaw from 'rehype-raw';
import remarkFrontmatter from 'remark-frontmatter';
import remarkGfm from 'remark-gfm';
import type { RemarkMdxFrontmatterOptions } from 'remark-mdx-frontmatter';
import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
import remarkShikiTwoslash from 'remark-shiki-twoslash';
import remarkSmartypants from 'remark-smartypants';
import remarkPrism from './remark-prism.js';
import { getFileInfo } from './utils.js';
@ -27,10 +27,7 @@ type MdxOptions = {
const DEFAULT_REMARK_PLUGINS = [remarkGfm, remarkSmartypants];
function handleExtends<T>(
config: WithExtends<T[] | undefined>,
defaults: T[] = [],
): T[] {
function handleExtends<T>(config: WithExtends<T[] | undefined>, defaults: T[] = []): T[] {
if (Array.isArray(config)) return config;
return [...defaults, ...(config?.extends ?? [])];

View file

@ -45,15 +45,16 @@ function runHighlighter(lang: string, code: string) {
/** */
export default function remarkPrism() {
return (tree: any) => visit(tree, 'code', (node: any) => {
let { lang, value } = node;
node.type = 'html';
return (tree: any) =>
visit(tree, 'code', (node: any) => {
let { lang, value } = node;
node.type = 'html';
let { html, classLanguage } = runHighlighter(lang, value);
let classes = [classLanguage];
node.value = `<pre class="${classes.join(
' '
)}"><code class="${classLanguage}">${html}</code></pre>`;
return node;
});
let { html, classLanguage } = runHighlighter(lang, value);
let classes = [classLanguage];
node.value = `<pre class="${classes.join(
' '
)}"><code class="${classLanguage}">${html}</code></pre>`;
return node;
});
}