full site update
This commit is contained in:
83
node_modules/@astrojs/markdown-remark/dist/index.js
generated
vendored
83
node_modules/@astrojs/markdown-remark/dist/index.js
generated
vendored
@@ -1,13 +1,3 @@
|
||||
import {
|
||||
InvalidAstroDataError,
|
||||
safelyGetAstroData,
|
||||
setVfileFrontmatter
|
||||
} from "./frontmatter-injection.js";
|
||||
import { loadPlugins } from "./load-plugins.js";
|
||||
import { rehypeHeadingIds } from "./rehype-collect-headings.js";
|
||||
import { rehypePrism } from "./rehype-prism.js";
|
||||
import { rehypeShiki } from "./rehype-shiki.js";
|
||||
import { remarkCollectImages } from "./remark-collect-images.js";
|
||||
import rehypeRaw from "rehype-raw";
|
||||
import rehypeStringify from "rehype-stringify";
|
||||
import remarkGfm from "remark-gfm";
|
||||
@@ -16,16 +6,32 @@ import remarkRehype from "remark-rehype";
|
||||
import remarkSmartypants from "remark-smartypants";
|
||||
import { unified } from "unified";
|
||||
import { VFile } from "vfile";
|
||||
import { defaultExcludeLanguages } from "./highlight.js";
|
||||
import { loadPlugins } from "./load-plugins.js";
|
||||
import { rehypeHeadingIds } from "./rehype-collect-headings.js";
|
||||
import { rehypeImages } from "./rehype-images.js";
|
||||
import { InvalidAstroDataError as InvalidAstroDataError2, setVfileFrontmatter as setVfileFrontmatter2 } from "./frontmatter-injection.js";
|
||||
import { rehypePrism } from "./rehype-prism.js";
|
||||
import { rehypeShiki } from "./rehype-shiki.js";
|
||||
import { remarkCollectImages } from "./remark-collect-images.js";
|
||||
import {
|
||||
extractFrontmatter,
|
||||
isFrontmatterValid,
|
||||
parseFrontmatter
|
||||
} from "./frontmatter.js";
|
||||
import { rehypeHeadingIds as rehypeHeadingIds2 } from "./rehype-collect-headings.js";
|
||||
import { remarkCollectImages as remarkCollectImages2 } from "./remark-collect-images.js";
|
||||
import { rehypePrism as rehypePrism2 } from "./rehype-prism.js";
|
||||
import { rehypeShiki as rehypeShiki2 } from "./rehype-shiki.js";
|
||||
import { createShikiHighlighter } from "./shiki.js";
|
||||
import { remarkCollectImages as remarkCollectImages2 } from "./remark-collect-images.js";
|
||||
import {
|
||||
createShikiHighlighter
|
||||
} from "./shiki.js";
|
||||
export * from "./types.js";
|
||||
const syntaxHighlightDefaults = {
|
||||
type: "shiki",
|
||||
excludeLangs: defaultExcludeLanguages
|
||||
};
|
||||
const markdownConfigDefaults = {
|
||||
syntaxHighlight: "shiki",
|
||||
syntaxHighlight: syntaxHighlightDefaults,
|
||||
shikiConfig: {
|
||||
langs: [],
|
||||
theme: "github-dark",
|
||||
@@ -49,7 +55,8 @@ async function createMarkdownProcessor(opts) {
|
||||
rehypePlugins = markdownConfigDefaults.rehypePlugins,
|
||||
remarkRehype: remarkRehypeOptions = markdownConfigDefaults.remarkRehype,
|
||||
gfm = markdownConfigDefaults.gfm,
|
||||
smartypants = markdownConfigDefaults.smartypants
|
||||
smartypants = markdownConfigDefaults.smartypants,
|
||||
experimentalHeadingIdCompat = false
|
||||
} = opts ?? {};
|
||||
const loadedRemarkPlugins = await Promise.all(loadPlugins(remarkPlugins));
|
||||
const loadedRehypePlugins = await Promise.all(loadPlugins(rehypePlugins));
|
||||
@@ -66,47 +73,53 @@ async function createMarkdownProcessor(opts) {
|
||||
parser.use(plugin, pluginOpts);
|
||||
}
|
||||
if (!isPerformanceBenchmark) {
|
||||
parser.use(remarkCollectImages);
|
||||
parser.use(remarkCollectImages, opts?.image);
|
||||
}
|
||||
parser.use(remarkRehype, {
|
||||
allowDangerousHtml: true,
|
||||
passThrough: [],
|
||||
...remarkRehypeOptions
|
||||
});
|
||||
if (!isPerformanceBenchmark) {
|
||||
if (syntaxHighlight === "shiki") {
|
||||
parser.use(rehypeShiki, shikiConfig);
|
||||
} else if (syntaxHighlight === "prism") {
|
||||
parser.use(rehypePrism);
|
||||
if (syntaxHighlight && !isPerformanceBenchmark) {
|
||||
const syntaxHighlightType = typeof syntaxHighlight === "string" ? syntaxHighlight : syntaxHighlight?.type;
|
||||
const excludeLangs = typeof syntaxHighlight === "object" ? syntaxHighlight?.excludeLangs : void 0;
|
||||
if (syntaxHighlightType === "shiki") {
|
||||
parser.use(rehypeShiki, shikiConfig, excludeLangs);
|
||||
} else if (syntaxHighlightType === "prism") {
|
||||
parser.use(rehypePrism, excludeLangs);
|
||||
}
|
||||
}
|
||||
for (const [plugin, pluginOpts] of loadedRehypePlugins) {
|
||||
parser.use(plugin, pluginOpts);
|
||||
}
|
||||
parser.use(rehypeImages());
|
||||
parser.use(rehypeImages);
|
||||
if (!isPerformanceBenchmark) {
|
||||
parser.use(rehypeHeadingIds);
|
||||
parser.use(rehypeHeadingIds, { experimentalHeadingIdCompat });
|
||||
}
|
||||
parser.use(rehypeRaw).use(rehypeStringify, { allowDangerousHtml: true });
|
||||
return {
|
||||
async render(content, renderOpts) {
|
||||
const vfile = new VFile({ value: content, path: renderOpts?.fileURL });
|
||||
setVfileFrontmatter(vfile, renderOpts?.frontmatter ?? {});
|
||||
const vfile = new VFile({
|
||||
value: content,
|
||||
path: renderOpts?.fileURL,
|
||||
data: {
|
||||
astro: {
|
||||
frontmatter: renderOpts?.frontmatter ?? {}
|
||||
}
|
||||
}
|
||||
});
|
||||
const result = await parser.process(vfile).catch((err) => {
|
||||
err = prefixError(err, `Failed to parse Markdown file "${vfile.path}"`);
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
const astroData = safelyGetAstroData(result.data);
|
||||
if (astroData instanceof InvalidAstroDataError) {
|
||||
throw astroData;
|
||||
}
|
||||
return {
|
||||
code: String(result.value),
|
||||
metadata: {
|
||||
headings: result.data.__astroHeadings ?? [],
|
||||
imagePaths: result.data.imagePaths ?? /* @__PURE__ */ new Set(),
|
||||
frontmatter: astroData.frontmatter ?? {}
|
||||
headings: result.data.astro?.headings ?? [],
|
||||
localImagePaths: result.data.astro?.localImagePaths ?? [],
|
||||
remoteImagePaths: result.data.astro?.remoteImagePaths ?? [],
|
||||
frontmatter: result.data.astro?.frontmatter ?? {}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -130,13 +143,15 @@ ${err.message}`;
|
||||
return wrappedError;
|
||||
}
|
||||
export {
|
||||
InvalidAstroDataError2 as InvalidAstroDataError,
|
||||
createMarkdownProcessor,
|
||||
createShikiHighlighter,
|
||||
extractFrontmatter,
|
||||
isFrontmatterValid,
|
||||
markdownConfigDefaults,
|
||||
parseFrontmatter,
|
||||
rehypeHeadingIds2 as rehypeHeadingIds,
|
||||
rehypePrism2 as rehypePrism,
|
||||
rehypeShiki2 as rehypeShiki,
|
||||
remarkCollectImages2 as remarkCollectImages,
|
||||
setVfileFrontmatter2 as setVfileFrontmatter
|
||||
syntaxHighlightDefaults
|
||||
};
|
||||
|
Reference in New Issue
Block a user