This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

View File

@@ -0,0 +1,10 @@
type Plugin = any;
export type AdmonitionOptions = {
keywords: string[];
extendDefaults: boolean;
};
export declare const DefaultAdmonitionOptions: AdmonitionOptions;
export declare function normalizeAdmonitionOptions(providedOptions: Partial<AdmonitionOptions> | true): AdmonitionOptions;
declare const plugin: Plugin;
export default plugin;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/admonitions/index.ts"],"names":[],"mappings":"AAiBA,KAAK,MAAM,GAAG,GAAG,CAAC;AAElB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAatC,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI,GACjD,iBAAiB,CAiBnB;AA6BD,QAAA,MAAM,MAAM,EAAE,MAuDb,CAAC;AAEF,eAAe,MAAM,CAAC"}

View File

@@ -0,0 +1,98 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeAdmonitionOptions = exports.DefaultAdmonitionOptions = void 0;
exports.DefaultAdmonitionOptions = {
keywords: [
'secondary',
'info',
'success',
'danger',
'note',
'tip',
'warning',
'important',
'caution',
],
extendDefaults: true,
};
function normalizeAdmonitionOptions(providedOptions) {
if (providedOptions === true) {
return exports.DefaultAdmonitionOptions;
}
const options = { ...exports.DefaultAdmonitionOptions, ...providedOptions };
// By default it makes more sense to append keywords to the default ones
// Adding custom keywords is more common than disabling existing ones
if (options.extendDefaults) {
options.keywords = [
...exports.DefaultAdmonitionOptions.keywords,
...options.keywords,
];
}
return options;
}
exports.normalizeAdmonitionOptions = normalizeAdmonitionOptions;
function parseDirective(directive) {
const hasDirectiveLabel =
// @ts-expect-error: fine
directive.children?.[0]?.data?.directiveLabel === true;
if (hasDirectiveLabel) {
const [directiveLabel, ...contentNodes] = directive.children;
return { directiveLabel: directiveLabel, contentNodes };
}
return { directiveLabel: undefined, contentNodes: directive.children };
}
function getTextOnlyTitle(directiveLabel) {
const isTextOnlyTitle = directiveLabel?.children?.length === 1 &&
directiveLabel?.children?.[0]?.type === 'text';
return isTextOnlyTitle
? // @ts-expect-error: todo type
directiveLabel?.children?.[0].value
: undefined;
}
const plugin = function plugin(optionsInput = {}) {
const { keywords } = normalizeAdmonitionOptions(optionsInput);
return async (root) => {
const { visit } = await import('unist-util-visit');
visit(root, (node) => {
if (node.type === 'containerDirective') {
const directive = node;
const isAdmonition = keywords.includes(directive.name);
if (!isAdmonition) {
return;
}
const { directiveLabel, contentNodes } = parseDirective(directive);
const textOnlyTitle = directive.attributes?.title ??
(directiveLabel ? getTextOnlyTitle(directiveLabel) : undefined);
// Transform the mdast directive node to a hast admonition node
// See https://github.com/syntax-tree/mdast-util-to-hast#fields-on-nodes
// TODO in MDX v2 we should transform the whole directive to
// mdxJsxFlowElement instead of using hast
directive.data = {
hName: 'admonition',
hProperties: {
...(textOnlyTitle && { title: textOnlyTitle }),
type: directive.name,
},
};
directive.children = contentNodes;
// TODO legacy MDX v1 <mdxAdmonitionTitle> workaround
// v1: not possible to inject complex JSX elements as props
// v2: now possible: use a mdxJsxFlowElement element
if (directiveLabel && !textOnlyTitle) {
const complexTitleNode = {
type: 'mdxAdmonitionTitle',
data: {
hName: 'mdxAdmonitionTitle',
hProperties: {},
},
children: directiveLabel.children,
};
// @ts-expect-error: invented node type
directive.children.unshift(complexTitleNode);
}
}
});
};
};
exports.default = plugin;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/admonitions/index.ts"],"names":[],"mappings":";;;AAwBa,QAAA,wBAAwB,GAAs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I,CAAC,aAAa,EAAE;oBACpC,MAAM,gBAAgB,GAAG;wBACvB,IAAI,EAAE,oBAAoB;wBAC1B,IAAI,EAAE;4BACJ,KAAK,EAAE,oBAAoB;4BAC3B,WAAW,EAAE,EAAE;yBAChB;wBACD,QAAQ,EAAE,cAAc,CAAC,QAAQ;qBAClC,CAAC;oBACF,uCAAuC;oBACvC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;iBAC9C;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}

View File

@@ -0,0 +1,15 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
type Plugin = any;
/**
* A remark plugin to extract the h1 heading found in Markdown files
* This is exposed as "data.contentTitle" to the processed vfile
* Also gives the ability to strip that content title (used for the blog plugin)
*/
declare const plugin: Plugin;
export default plugin;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/contentTitle/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,KAAK,MAAM,GAAG,GAAG,CAAC;AAMlB;;;;GAIG;AACH,QAAA,MAAM,MAAM,EAAE,MA0Bb,CAAC;AAEF,eAAe,MAAM,CAAC"}

View File

@@ -0,0 +1,38 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* A remark plugin to extract the h1 heading found in Markdown files
* This is exposed as "data.contentTitle" to the processed vfile
* Also gives the ability to strip that content title (used for the blog plugin)
*/
const plugin = function plugin(options = {}) {
// content title is
const removeContentTitle = options.removeContentTitle ?? false;
return async (root, vfile) => {
const { toString } = await import('mdast-util-to-string');
const { visit, EXIT } = await import('unist-util-visit');
visit(root, 'heading', (headingNode, index, parent) => {
if (headingNode.depth === 1) {
vfile.data.contentTitle = toString(headingNode);
if (removeContentTitle) {
// @ts-expect-error: TODO how to fix?
parent.children.splice(index, 1);
}
return EXIT; // We only handle the very first heading
}
// We only handle contentTitle if it's the very first heading found
if (headingNode.depth >= 1) {
return EXIT;
}
return undefined;
});
};
};
exports.default = plugin;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/contentTitle/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAgBH;;;;GAIG;AACH,MAAM,MAAM,GAAW,SAAS,MAAM,CACpC,UAAyB,EAAE;IAE3B,mBAAmB;IACnB,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,KAAK,CAAC;IAE/D,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC3B,MAAM,EAAC,QAAQ,EAAC,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;QACxD,MAAM,EAAC,KAAK,EAAE,IAAI,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAEvD,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,WAAoB,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAC7D,IAAI,WAAW,CAAC,KAAK,KAAK,CAAC,EAAE;gBAC3B,KAAK,CAAC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;gBAChD,IAAI,kBAAkB,EAAE;oBACtB,qCAAqC;oBACrC,MAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBACnC;gBACD,OAAO,IAAI,CAAC,CAAC,wCAAwC;aACtD;YACD,mEAAmE;YACnE,IAAI,WAAW,CAAC,KAAK,IAAI,CAAC,EAAE;gBAC1B,OAAO,IAAI,CAAC;aACb;YACD,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}

View File

@@ -0,0 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Transformer } from 'unified';
export default function plugin(): Transformer;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/details/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAOzC,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,WAAW,CAS5C"}

View File

@@ -0,0 +1,22 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
// Transform <details> to <Details>
// MDX 2 doesn't allow to substitute html elements with the provider anymore
function plugin() {
return async (root) => {
const { visit } = await import('unist-util-visit');
visit(root, 'mdxJsxFlowElement', (node) => {
if (node.name === 'details') {
node.name = 'Details';
}
});
};
}
exports.default = plugin;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/details/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAQH,mCAAmC;AACnC,4EAA4E;AAC5E,SAAwB,MAAM;IAC5B,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACjD,KAAK,CAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC,IAAuB,EAAE,EAAE;YAC3D,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;gBAC3B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;aACvB;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AATD,yBASC"}

View File

@@ -0,0 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Transformer } from 'unified';
export default function plugin(): Transformer;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/head/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAOzC,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,WAAW,CAS5C"}

View File

@@ -0,0 +1,22 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
// Transform <head> to <Head>
// MDX 2 doesn't allow to substitute html elements with the provider anymore
function plugin() {
return async (root) => {
const { visit } = await import('unist-util-visit');
visit(root, 'mdxJsxFlowElement', (node) => {
if (node.name === 'head') {
node.name = 'Head';
}
});
};
}
exports.default = plugin;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/head/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAQH,6BAA6B;AAC7B,4EAA4E;AAC5E,SAAwB,MAAM;IAC5B,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACjD,KAAK,CAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC,IAAuB,EAAE,EAAE;YAC3D,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE;gBACxB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;aACpB;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AATD,yBASC"}

View File

@@ -0,0 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Transformer } from 'unified';
export default function plugin(): Transformer;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/headings/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAGzC,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,WAAW,CAyD5C"}

View File

@@ -0,0 +1,57 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/* Based on remark-slug (https://github.com/remarkjs/remark-slug) and gatsby-remark-autolink-headers (https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-remark-autolink-headers) */
const utils_1 = require("@docusaurus/utils");
function plugin() {
return async (root) => {
const { toString } = await import('mdast-util-to-string');
const { visit } = await import('unist-util-visit');
const slugs = (0, utils_1.createSlugger)();
visit(root, 'heading', (headingNode) => {
const data = headingNode.data ?? (headingNode.data = {});
const properties = (data.hProperties || (data.hProperties = {}));
let { id } = properties;
if (id) {
id = slugs.slug(id, { maintainCase: true });
}
else {
const headingTextNodes = headingNode.children.filter(({ type }) => !['html', 'jsx'].includes(type));
const heading = toString(headingTextNodes.length > 0 ? headingTextNodes : headingNode);
// Support explicit heading IDs
const parsedHeading = (0, utils_1.parseMarkdownHeadingId)(heading);
id = parsedHeading.id ?? slugs.slug(heading);
if (parsedHeading.id) {
// When there's an id, it is always in the last child node
// Sometimes heading is in multiple "parts" (** syntax creates a child
// node):
// ## part1 *part2* part3 {#id}
const lastNode = headingNode.children[headingNode.children.length - 1];
if (headingNode.children.length > 1) {
const lastNodeText = (0, utils_1.parseMarkdownHeadingId)(lastNode.value).text;
// When last part contains test+id, remove the id
if (lastNodeText) {
lastNode.value = lastNodeText;
}
// When last part contains only the id: completely remove that node
else {
headingNode.children.pop();
}
}
else {
lastNode.value = parsedHeading.text;
}
}
}
data.id = id;
properties.id = id;
});
};
}
exports.default = plugin;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/headings/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,gMAAgM;AAEhM,6CAAwE;AAKxE,SAAwB,MAAM;IAC5B,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,MAAM,EAAC,QAAQ,EAAC,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;QACxD,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAEjD,MAAM,KAAK,GAAG,IAAA,qBAAa,GAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,WAAoB,EAAE,EAAE;YAC9C,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;YACzD,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,CAE9D,CAAC;YACF,IAAI,EAAC,EAAE,EAAC,GAAG,UAAU,CAAC;YAEtB,IAAI,EAAE,EAAE;gBACN,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,YAAY,EAAE,IAAI,EAAC,CAAC,CAAC;aAC3C;iBAAM;gBACL,MAAM,gBAAgB,GAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,CAClD,CAAC,EAAC,IAAI,EAAC,EAAE,EA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under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Transformer, Processor } from 'unified';
export default function codeCompatPlugin(this: Processor): Transformer;
//# sourceMappingURL=codeCompatPlugin.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"codeCompatPlugin.d.ts","sourceRoot":"","sources":["../../../src/remark/mdx1Compat/codeCompatPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,SAAS,CAAC;AAUpD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,CAerE"}

View File

@@ -0,0 +1,29 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
// Solution inspired by https://github.com/pomber/docusaurus-mdx-2/blob/main/packages/mdx-loader/src/remark/codeCompat/index.ts
// TODO after MDX 2 we probably don't need this - remove soon?
// Only fenced code blocks are swapped by pre/code MDX components
// Using <pre><code> in JSX shouldn't use our MDX components anymore
// To make theme-classic/src/theme/MDXComponents/Pre work
// we need to fill two properties that mdx v2 doesn't provide anymore
function codeCompatPlugin() {
return async (root) => {
const { visit } = await import('unist-util-visit');
visit(root, 'code', (node) => {
node.data = node.data || {};
node.data.hProperties = node.data.hProperties || {};
node.data.hProperties.metastring = node.meta;
// Retrocompatible support for live codeblock metastring
// Not really the appropriate place to handle that :s
node.data.hProperties.live = node.meta?.split(' ').includes('live');
});
};
}
exports.default = codeCompatPlugin;
//# sourceMappingURL=codeCompatPlugin.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"codeCompatPlugin.js","sourceRoot":"","sources":["../../../src/remark/mdx1Compat/codeCompatPlugin.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAMH,+HAA+H;AAC/H,8DAA8D;AAC9D,iEAAiE;AACjE,oEAAoE;AAEpE,yDAAyD;AACzD,qEAAqE;AACrE,SAAwB,gBAAgB;IACtC,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAEjD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,IAAU,EAAE,EAAE;YACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;YAE5B,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;YACpD,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC;YAE7C,wDAAwD;YACxD,qDAAqD;YACrD,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAfD,mCAeC"}

View File

@@ -0,0 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Transformer } from 'unified';
export default function plugin(): Transformer;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/mermaid/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAOzC,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,WAAW,CAmB5C"}

View File

@@ -0,0 +1,34 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../utils");
// TODO: this plugin shouldn't be in the core MDX loader
// After we allow plugins to provide Remark/Rehype plugins (see
// https://github.com/facebook/docusaurus/issues/6370), this should be provided
// by theme-mermaid itself
function plugin() {
return async (root) => {
const { visit } = await import('unist-util-visit');
visit(root, 'code', (node) => {
if (node.lang === 'mermaid') {
// TODO migrate to mdxJsxFlowElement? cf admonitions
(0, utils_1.transformNode)(node, {
type: 'mermaidCodeBlock',
data: {
hName: 'mermaid',
hProperties: {
value: node.value,
},
},
});
}
});
};
}
exports.default = plugin;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/mermaid/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,oCAAuC;AAMvC,wDAAwD;AACxD,+DAA+D;AAC/D,+EAA+E;AAC/E,0BAA0B;AAC1B,SAAwB,MAAM;IAC5B,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAEjD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,IAAU,EAAE,EAAE;YACjC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;gBAC3B,oDAAoD;gBACpD,IAAA,qBAAa,EAAC,IAAI,EAAE;oBAClB,IAAI,EAAE,kBAAkB;oBACxB,IAAI,EAAE;wBACJ,KAAK,EAAE,SAAS;wBAChB,WAAW,EAAE;4BACX,KAAK,EAAE,IAAI,CAAC,KAAK;yBAClB;qBACF;iBACF,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAnBD,yBAmBC"}

View File

@@ -0,0 +1,15 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
type Plugin = any;
export type TOCItem = {
readonly value: string;
readonly id: string;
readonly level: number;
};
declare const plugin: Plugin;
export default plugin;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/toc/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH,KAAK,MAAM,GAAG,GAAG,CAAC;AAElB,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAuDF,QAAA,MAAM,MAAM,EAAE,MAiCb,CAAC;AAEF,eAAe,MAAM,CAAC"}

View File

@@ -0,0 +1,111 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const parser_1 = require("@babel/parser");
const traverse_1 = tslib_1.__importDefault(require("@babel/traverse"));
const stringify_object_1 = tslib_1.__importDefault(require("stringify-object"));
const utils_1 = require("../utils");
const parseOptions = {
plugins: ['jsx'],
sourceType: 'module',
};
const isImport = (child) => child.type === 'mdxjsEsm' && child.value.startsWith('import');
const hasImports = (index) => index > -1;
const isExport = (child) => child.type === 'mdxjsEsm' && child.value.startsWith('export');
const isTarget = (child, name) => {
let found = false;
const ast = (0, parser_1.parse)(child.value, parseOptions);
(0, traverse_1.default)(ast, {
VariableDeclarator: (path) => {
if (path.node.id.name === name) {
found = true;
}
},
});
return found;
};
const getOrCreateExistingTargetIndex = async (children, name) => {
let importsIndex = -1;
let targetIndex = -1;
children.forEach((child, index) => {
if (isImport(child)) {
importsIndex = index;
}
else if (isExport(child) && isTarget(child, name)) {
targetIndex = index;
}
});
if (targetIndex === -1) {
const target = await createExportNode(name, []);
targetIndex = hasImports(importsIndex) ? importsIndex + 1 : 0;
children.splice(targetIndex, 0, target);
}
return targetIndex;
};
const plugin = function plugin(options = {}) {
const name = options.name || 'toc';
return async (root) => {
const { toString } = await import('mdast-util-to-string');
const { visit } = await import('unist-util-visit');
const headings = [];
visit(root, 'heading', (child) => {
const value = toString(child);
// depth:1 headings are titles and not included in the TOC
if (!value || child.depth < 2) {
return;
}
headings.push({
value: (0, utils_1.toValue)(child, toString),
id: child.data.id,
level: child.depth,
});
});
const { children } = root;
const targetIndex = await getOrCreateExistingTargetIndex(children, name);
if (headings?.length) {
children[targetIndex] = await createExportNode(name, headings);
}
};
};
exports.default = plugin;
async function createExportNode(name, object) {
const { valueToEstree } = await import('estree-util-value-to-estree');
return {
type: 'mdxjsEsm',
value: `export const ${name} = ${(0, stringify_object_1.default)(object)}`,
data: {
estree: {
type: 'Program',
body: [
{
type: 'ExportNamedDeclaration',
declaration: {
type: 'VariableDeclaration',
declarations: [
{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name,
},
init: valueToEstree(object),
},
],
kind: 'const',
},
specifiers: [],
source: null,
},
],
sourceType: 'module',
},
},
};
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/toc/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,0CAAwD;AACxD,uEAAuC;AACvC,gFAA+C;AAC/C,oCAAiC;AAuBjC,MAAM,YAAY,GAAkB;IAClC,OAAO,EAAE,CAAC,KAAK,CAAC;IAChB,UAAU,EAAE,QAAQ;CACrB,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAoB,EAAE,CAChD,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAChE,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AACjD,MAAM,QAAQ,GAAG,CAAC,KAAU,EA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AEtB,KAAK,UAAU,gBAAgB,CAAC,IAAY,EAAE,MAAW;IACvD,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;IAEpE,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,gBAAgB,IAAI,MAAM,IAAA,0BAAe,EAAC,MAAM,CAAC,EAAE;QAC1D,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE;oBACJ;wBACE,IAAI,EAAE,wBAAwB;wBAC9B,WAAW,EAAE;4BACX,IAAI,EAAE,qBAAqB;4BAC3B,YAAY,EAAE;gCACZ;oCACE,IAAI,EAAE,oBAAoB;oCAC1B,EAAE,EAAE;wCACF,IAAI,EAAE,YAAY;wCAClB,IAAI;qCACL;oCACD,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC;iCAC5B;6BACF;4BACD,IAAI,EAAE,OAAO;yBACd;wBACD,UAAU,EAAE,EAAE;wBACd,MAAM,EAAE,IAAI;qBACb;iBACF;gBACD,UAAU,EAAE,QAAQ;aACrB;SACF;KACF,CAAC;AACJ,CAAC"}

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Transformer } from 'unified';
type PluginOptions = {
staticDirs: string[];
siteDir: string;
};
export default function plugin(options: PluginOptions): Transformer;
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/transformImage/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAUzC,KAAK,aAAa,GAAG;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA2JF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,WAAW,CAelE"}

View File

@@ -0,0 +1,142 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const path_1 = tslib_1.__importDefault(require("path"));
const url_1 = tslib_1.__importDefault(require("url"));
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const util_1 = require("util");
const utils_1 = require("@docusaurus/utils");
const escape_html_1 = tslib_1.__importDefault(require("escape-html"));
const image_size_1 = tslib_1.__importDefault(require("image-size"));
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
const utils_2 = require("../utils");
const { loaders: { inlineMarkdownImageFileLoader }, } = (0, utils_1.getFileLoaderUtils)();
async function toImageRequireNode([node], imagePath, filePath) {
// MdxJsxTextElement => see https://github.com/facebook/docusaurus/pull/8288#discussion_r1125871405
const jsxNode = node;
const attributes = [];
let relativeImagePath = (0, utils_1.posixPath)(path_1.default.relative(path_1.default.dirname(filePath), imagePath));
relativeImagePath = `./${relativeImagePath}`;
const parsedUrl = url_1.default.parse(node.url);
const hash = parsedUrl.hash ?? '';
const search = parsedUrl.search ?? '';
const requireString = `${inlineMarkdownImageFileLoader}${(0, utils_1.escapePath)(relativeImagePath) + search}`;
if (node.alt) {
attributes.push({
type: 'mdxJsxAttribute',
name: 'alt',
value: (0, escape_html_1.default)(node.alt),
});
}
attributes.push({
type: 'mdxJsxAttribute',
name: 'src',
value: (0, utils_2.assetRequireAttributeValue)(requireString, hash),
});
if (node.title) {
attributes.push({
type: 'mdxJsxAttribute',
name: 'title',
value: (0, escape_html_1.default)(node.title),
});
}
try {
const size = (await (0, util_1.promisify)(image_size_1.default)(imagePath));
if (size.width) {
attributes.push({
type: 'mdxJsxAttribute',
name: 'width',
value: String(size.width),
});
}
if (size.height) {
attributes.push({
type: 'mdxJsxAttribute',
name: 'height',
value: String(size.height),
});
}
}
catch (err) {
// Workaround for https://github.com/yarnpkg/berry/pull/3889#issuecomment-1034469784
// TODO remove this check once fixed in Yarn PnP
if (!process.versions.pnp) {
logger_1.default.warn `The image at path=${imagePath} can't be read correctly. Please ensure it's a valid image.
${err.message}`;
}
}
(0, utils_2.transformNode)(jsxNode, {
type: 'mdxJsxTextElement',
name: 'img',
attributes,
children: [],
});
}
async function ensureImageFileExist(imagePath, sourceFilePath) {
const imageExists = await fs_extra_1.default.pathExists(imagePath);
if (!imageExists) {
throw new Error(`Image ${(0, utils_1.toMessageRelativeFilePath)(imagePath)} used in ${(0, utils_1.toMessageRelativeFilePath)(sourceFilePath)} not found.`);
}
}
async function getImageAbsolutePath(imagePath, { siteDir, filePath, staticDirs }) {
if (imagePath.startsWith('@site/')) {
const imageFilePath = path_1.default.join(siteDir, imagePath.replace('@site/', ''));
await ensureImageFileExist(imageFilePath, filePath);
return imageFilePath;
}
else if (path_1.default.isAbsolute(imagePath)) {
// Absolute paths are expected to exist in the static folder.
const possiblePaths = staticDirs.map((dir) => path_1.default.join(dir, imagePath));
const imageFilePath = await (0, utils_1.findAsyncSequential)(possiblePaths, fs_extra_1.default.pathExists);
if (!imageFilePath) {
throw new Error(`Image ${possiblePaths
.map((p) => (0, utils_1.toMessageRelativeFilePath)(p))
.join(' or ')} used in ${(0, utils_1.toMessageRelativeFilePath)(filePath)} not found.`);
}
return imageFilePath;
}
// relative paths are resolved against the source file's folder
const imageFilePath = path_1.default.join(path_1.default.dirname(filePath), decodeURIComponent(imagePath));
await ensureImageFileExist(imageFilePath, filePath);
return imageFilePath;
}
async function processImageNode(target, context) {
const [node] = target;
if (!node.url) {
throw new Error(`Markdown image URL is mandatory in "${(0, utils_1.toMessageRelativeFilePath)(context.filePath)}" file`);
}
const parsedUrl = url_1.default.parse(node.url);
if (parsedUrl.protocol || !parsedUrl.pathname) {
// pathname:// is an escape hatch, in case user does not want her images to
// be converted to require calls going through webpack loader
if (parsedUrl.protocol === 'pathname:') {
node.url = node.url.replace('pathname://', '');
}
return;
}
// We try to convert image urls without protocol to images with require calls
// going through webpack ensures that image assets exist at build time
const imagePath = await getImageAbsolutePath(parsedUrl.pathname, context);
await toImageRequireNode(target, imagePath, context.filePath);
}
function plugin(options) {
return async (root, vfile) => {
const { visit } = await import('unist-util-visit');
const promises = [];
visit(root, 'image', (node, index, parent) => {
promises.push(processImageNode([node, index, parent], {
...options,
filePath: vfile.path,
}));
});
await Promise.all(promises);
};
}
exports.default = plugin;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/transformImage/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,wDAAwB;AACxB,sDAAsB;AACtB,gEAA0B;AAC1B,+BAA+B;AAC/B,6CAM2B;AAC3B,sEAAqC;AACrC,oEAAgC;AAChC,wEAAwC;AACxC,oCAAmE;AAQnE,MAAM,EACJ,OAAO,EAAE,EAAC,6BAA6B,EAAC,GACzC,GAAG,IAAA,0BAAkB,GAAE,CAAC;AAazB,KAAK,UAAU,kBAAkB,CAC/B,CAAC,IAAI,CAAS,EACd,SAAiB,EACjB,QAAgB;IAEhB,mGAAmG;IACnG,MAAM,OAAO,GAAG,IAAoC,CAAC;IACrD,MAAM,UAAU,GAAoC,EAAE,CAAC;IAEvD,IAAI,iBAAiB,GAAG,IAAA,iBAAS,EAC/B,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CACjD,CAAC;IACF,iBAAiB,GAAG,KAAK,iBAAiB,EAAE,CAAC;IAE7C,MAAM,SAAS,GAAG,aAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC;IACtC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AAM,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAChE,CAAC;AAED,SAAwB,MAAM,CAAC,OAAsB;IACnD,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC3B,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAEjD,MAAM,QAAQ,GAAoB,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,IAAW,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAClD,QAAQ,CAAC,IAAI,CACX,gBAAgB,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,MAAO,CAAC,EAAE;gBACvC,GAAG,OAAO;gBACV,QAAQ,EAAE,KAAK,CAAC,IAAK;aACtB,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC;AAfD,yBAeC"}

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Transformer } from 'unified';
type PluginOptions = {
staticDirs: string[];
siteDir: string;
};
export default function plugin(options: PluginOptions): Transformer;
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/transformLinks/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAUzC,KAAK,aAAa,GAAG;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAyKF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,WAAW,CAelE"}

View File

@@ -0,0 +1,153 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const path_1 = tslib_1.__importDefault(require("path"));
const url_1 = tslib_1.__importDefault(require("url"));
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const utils_1 = require("@docusaurus/utils");
const escape_html_1 = tslib_1.__importDefault(require("escape-html"));
const utils_2 = require("../utils");
const { loaders: { inlineMarkdownLinkFileLoader }, } = (0, utils_1.getFileLoaderUtils)();
/**
* Transforms the link node to a JSX `<a>` element with a `require()` call.
*/
async function toAssetRequireNode([node], assetPath, filePath) {
// MdxJsxTextElement => see https://github.com/facebook/docusaurus/pull/8288#discussion_r1125871405
const jsxNode = node;
const attributes = [];
// require("assets/file.pdf") means requiring from a package called assets
const relativeAssetPath = `./${(0, utils_1.posixPath)(path_1.default.relative(path_1.default.dirname(filePath), assetPath))}`;
const parsedUrl = url_1.default.parse(node.url);
const hash = parsedUrl.hash ?? '';
const search = parsedUrl.search ?? '';
const requireString = `${
// A hack to stop Webpack from using its built-in loader to parse JSON
path_1.default.extname(relativeAssetPath) === '.json'
? `${relativeAssetPath.replace('.json', '.raw')}!=`
: ''}${inlineMarkdownLinkFileLoader}${(0, utils_1.escapePath)(relativeAssetPath) + search}`;
attributes.push({
type: 'mdxJsxAttribute',
name: 'target',
value: '_blank',
});
// Assets are not routes, and are required by Webpack already
// They should not trigger the broken link checker
attributes.push({
type: 'mdxJsxAttribute',
name: 'data-noBrokenLinkCheck',
value: {
type: 'mdxJsxAttributeValueExpression',
value: 'true',
data: {
estree: {
type: 'Program',
body: [
{
type: 'ExpressionStatement',
expression: {
type: 'Literal',
value: true,
raw: 'true',
},
},
],
sourceType: 'module',
comments: [],
},
},
},
});
attributes.push({
type: 'mdxJsxAttribute',
name: 'href',
value: (0, utils_2.assetRequireAttributeValue)(requireString, hash),
});
if (node.title) {
attributes.push({
type: 'mdxJsxAttribute',
name: 'title',
value: (0, escape_html_1.default)(node.title),
});
}
const { children } = node;
(0, utils_2.transformNode)(jsxNode, {
type: 'mdxJsxTextElement',
name: 'a',
attributes,
children,
});
}
async function ensureAssetFileExist(assetPath, sourceFilePath) {
const assetExists = await fs_extra_1.default.pathExists(assetPath);
if (!assetExists) {
throw new Error(`Asset ${(0, utils_1.toMessageRelativeFilePath)(assetPath)} used in ${(0, utils_1.toMessageRelativeFilePath)(sourceFilePath)} not found.`);
}
}
async function getAssetAbsolutePath(assetPath, { siteDir, filePath, staticDirs }) {
if (assetPath.startsWith('@site/')) {
const assetFilePath = path_1.default.join(siteDir, assetPath.replace('@site/', ''));
// The @site alias is the only way to believe that the user wants an asset.
// Everything else can just be a link URL
await ensureAssetFileExist(assetFilePath, filePath);
return assetFilePath;
}
else if (path_1.default.isAbsolute(assetPath)) {
const assetFilePath = await (0, utils_1.findAsyncSequential)(staticDirs.map((dir) => path_1.default.join(dir, assetPath)), fs_extra_1.default.pathExists);
if (assetFilePath) {
return assetFilePath;
}
}
else {
const assetFilePath = path_1.default.join(path_1.default.dirname(filePath), assetPath);
if (await fs_extra_1.default.pathExists(assetFilePath)) {
return assetFilePath;
}
}
return null;
}
async function processLinkNode(target, context) {
const [node] = target;
if (!node.url) {
// Try to improve error feedback
// see https://github.com/facebook/docusaurus/issues/3309#issuecomment-690371675
const title = node.title ?? node.children[0]?.value ?? '?';
const line = node.position?.start.line ?? '?';
throw new Error(`Markdown link URL is mandatory in "${(0, utils_1.toMessageRelativeFilePath)(context.filePath)}" file (title: ${title}, line: ${line}).`);
}
const parsedUrl = url_1.default.parse(node.url);
if (parsedUrl.protocol || !parsedUrl.pathname) {
// Don't process pathname:// here, it's used by the <Link> component
return;
}
const hasSiteAlias = parsedUrl.pathname.startsWith('@site/');
const hasAssetLikeExtension = path_1.default.extname(parsedUrl.pathname) &&
!parsedUrl.pathname.match(/\.(?:mdx?|html)(?:#|$)/);
if (!hasSiteAlias && !hasAssetLikeExtension) {
return;
}
const assetPath = await getAssetAbsolutePath(decodeURIComponent(parsedUrl.pathname), context);
if (assetPath) {
await toAssetRequireNode(target, assetPath, context.filePath);
}
}
function plugin(options) {
return async (root, vfile) => {
const { visit } = await import('unist-util-visit');
const promises = [];
visit(root, 'link', (node, index, parent) => {
promises.push(processLinkNode([node, index, parent], {
...options,
filePath: vfile.path,
}));
});
await Promise.all(promises);
};
}
exports.default = plugin;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/transformLinks/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,wDAAwB;AACxB,sDAAsB;AACtB,gEAA0B;AAC1B,6CAM2B;AAC3B,sEAAqC;AACrC,oCAAmE;AAQnE,MAAM,EACJ,OAAO,EAAE,EAAC,4BAA4B,EAAC,GACxC,GAAG,IAAA,0BAAkB,GAAE,CAAC;AAazB;;GAEG;AACH,KAAK,UAAU,kBAAkB,CAC/B,CAAC,IAAI,CAAS,EACd,SAAiB,EACjB,QAAgB;IAEhB,mGAAmG;IACnG,MAAM,OAAO,GAAG,IAAoC,CAAC;IACrD,MAAM,UAAU,GAAoC,EAAE,CAAC;IAEvD,0EAA0E;IAC1E,MAAM,iBAAiB,GAAG,KAAK,IAAA,iBAAS,EACtC,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CACjD,EAAE,CAAC;IAEJ,MAAM,SAAS,GAAG,aAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC;IAEtC,MAAM,aAAa,GAAG,GAAG;IACvB,sEAAsE;IACtE,cAAI,CAAC,OAA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AAI,SAAS,EAAE;QACb,MAAM,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;KAC/D;AACH,CAAC;AAED,SAAwB,MAAM,CAAC,OAAsB;IACnD,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC3B,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAEjD,MAAM,QAAQ,GAAoB,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,IAAU,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAChD,QAAQ,CAAC,IAAI,CACX,eAAe,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,MAAO,CAAC,EAAE;gBACtC,GAAG,OAAO;gBACV,QAAQ,EAAE,KAAK,CAAC,IAAK;aACtB,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC;AAfD,yBAeC"}

View File

@@ -0,0 +1,4 @@
type Plugin = any;
declare const plugin: Plugin;
export default plugin;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/unusedDirectives/index.ts"],"names":[],"mappings":"AAwBA,KAAK,MAAM,GAAG,GAAG,CAAC;AA4GlB,QAAA,MAAM,MAAM,EAAE,MAgCb,CAAC;AAEF,eAAe,MAAM,CAAC"}

View File

@@ -0,0 +1,117 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const path_1 = tslib_1.__importDefault(require("path"));
const process_1 = tslib_1.__importDefault(require("process"));
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
const utils_1 = require("@docusaurus/utils");
const utils_2 = require("../utils");
const directiveTypes = [
'containerDirective',
'leafDirective',
'textDirective',
];
const directivePrefixMap = {
textDirective: ':',
leafDirective: '::',
containerDirective: ':::',
};
function formatDirectiveName(directive) {
const prefix = directivePrefixMap[directive.type];
if (!prefix) {
throw new Error(`unexpected, no prefix found for directive of type ${directive.type}`);
}
// To simplify we don't display the eventual label/props of directives
return `${prefix}${directive.name}`;
}
function formatDirectivePosition(directive) {
return directive.position?.start
? logger_1.default.interpolate `number=${directive.position.start.line}:number=${directive.position.start.column}`
: undefined;
}
function formatUnusedDirectiveMessage(directive) {
const name = formatDirectiveName(directive);
const position = formatDirectivePosition(directive);
return `- ${name} ${position ? `(${position})` : ''}`;
}
function formatUnusedDirectivesMessage({ directives, filePath, }) {
const supportUrl = 'https://github.com/facebook/docusaurus/pull/9394';
const customPath = (0, utils_1.posixPath)(path_1.default.relative(process_1.default.cwd(), filePath));
const warningTitle = logger_1.default.interpolate `Docusaurus found ${directives.length} unused Markdown directives in file path=${customPath}`;
const customSupportUrl = logger_1.default.interpolate `url=${supportUrl}`;
const warningMessages = directives
.map(formatUnusedDirectiveMessage)
.join('\n');
return `${warningTitle}
${warningMessages}
Your content might render in an unexpected way. Visit ${customSupportUrl} to find out why and how to fix it.`;
}
function logUnusedDirectivesWarning({ directives, filePath, }) {
if (directives.length > 0) {
const message = formatUnusedDirectivesMessage({
directives,
filePath,
});
logger_1.default.warn(message);
}
}
function isTextDirective(directive) {
return directive.type === 'textDirective';
}
// A simple text directive is one without any label/props
function isSimpleTextDirective(directive) {
if (isTextDirective(directive)) {
// Attributes in MDAST = Directive props
const hasAttributes = directive.attributes && Object.keys(directive.attributes).length > 0;
// Children in MDAST = Directive label
const hasChildren = directive.children.length > 0;
return !hasAttributes && !hasChildren;
}
return false;
}
function transformSimpleTextDirectiveToString(textDirective) {
(0, utils_2.transformNode)(textDirective, {
type: 'text',
value: `:${textDirective.name}`, // We ignore label/props on purpose here
});
}
function isUnusedDirective(directive) {
// If directive data is set (notably hName/hProperties set by admonitions)
// this usually means the directive has been handled by another plugin
return !directive.data;
}
const plugin = function plugin() {
return async (tree, file) => {
const { visit } = await import('unist-util-visit');
const unusedDirectives = [];
visit(tree, directiveTypes, (directive) => {
// If directive data is set (hName/hProperties set by admonitions)
// this usually means the directive has been handled by another plugin
if (isUnusedDirective(directive)) {
if (isSimpleTextDirective(directive)) {
transformSimpleTextDirectiveToString(directive);
}
else {
unusedDirectives.push(directive);
}
}
});
// We only enable these warnings for the client compiler
// This avoids emitting duplicate warnings in prod mode
// Note: the client compiler is used in both dev/prod modes
if (file.data.compilerName === 'client') {
logUnusedDirectivesWarning({
directives: unusedDirectives,
filePath: file.path,
});
}
};
};
exports.default = plugin;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/unusedDirectives/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,wDAAwB;AACxB,8DAA8B;AAC9B,wEAAwC;AACxC,6CAA4C;AAC5C,oCAAuC;AAkBvC,MAAM,cAAc,GAAoB;IACtC,oBAAoB;IACpB,eAAe;IACf,eAAe;CAChB,CAAC;AAEF,MAAM,kBAAkB,GAAqC;IAC3D,aAAa,EAAE,GAAG;IAClB,aAAa,EAAE,IAAI;IACnB,kBAAkB,EAAE,KAAK;CAC1B,CAAC;AAEF,SAAS,mBAAmB,CAAC,SAAqB;IAChD,MAAM,MAAM,GAAG,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CACb,qDAAqD,SAAS,CAAC,IAAI,EAAE,CACtE,CAAC;KACH;IACD,sEAAsE;IACtE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;AACtC,CAAC;AAED,SAAS,uBAAuB,CAAC,SAAqB;IACpD,OAAO,SAAS,CA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AChC,IAAI,qBAAqB,CAAC,SAAS,CAAC,EAAE;oBACpC,oCAAoC,CAAC,SAAS,CAAC,CAAC;iBACjD;qBAAM;oBACL,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;iBAClC;aACF;QACH,CAAC,CACF,CAAC;QAEF,wDAAwD;QACxD,uDAAuD;QACvD,2DAA2D;QAC3D,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,KAAK,QAAQ,EAAE;YACvC,0BAA0B,CAAC;gBACzB,UAAU,EAAE,gBAAgB;gBAC5B,QAAQ,EAAE,IAAI,CAAC,IAAI;aACpB,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}

View File

@@ -0,0 +1,20 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Parent, Node } from 'unist';
import type { PhrasingContent, Heading } from 'mdast';
import type { MdxJsxAttributeValueExpression, MdxJsxTextElement } from 'mdast-util-mdx';
/**
* Util to transform one node type to another node type
* The input node is mutated in place
* @param node the node to mutate
* @param newNode what the original node should become become
*/
export declare function transformNode<NewNode extends Node>(node: Node, newNode: NewNode): NewNode;
export declare function stringifyContent(node: Parent, toString: (param: unknown) => string): string;
export declare function toValue(node: PhrasingContent | Heading | MdxJsxTextElement, toString: (param: unknown) => string): string;
export declare function assetRequireAttributeValue(requireString: string, hash: string): MdxJsxAttributeValueExpression;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAC,eAAe,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AACpD,OAAO,KAAK,EAEV,8BAA8B,EAC9B,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AAExB;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,IAAI,EAChD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,GACf,OAAO,CAUT;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GACnC,MAAM,CAIR;AA8BD,wBAAgB,OAAO,CACrB,IAAI,EAAE,eAAe,GAAG,OAAO,GAAG,iBAAiB,EACnD,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GACnC,MAAM,CAsBR;AAED,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GACX,8BAA8B,CAkDhC"}

View File

@@ -0,0 +1,127 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.assetRequireAttributeValue = exports.toValue = exports.stringifyContent = exports.transformNode = void 0;
const tslib_1 = require("tslib");
const escape_html_1 = tslib_1.__importDefault(require("escape-html"));
/**
* Util to transform one node type to another node type
* The input node is mutated in place
* @param node the node to mutate
* @param newNode what the original node should become become
*/
function transformNode(node, newNode) {
Object.keys(node).forEach((key) => {
// @ts-expect-error: unsafe but ok
delete node[key];
});
Object.keys(newNode).forEach((key) => {
// @ts-expect-error: unsafe but ok
node[key] = newNode[key];
});
return node;
}
exports.transformNode = transformNode;
function stringifyContent(node, toString) {
return node.children
.map((item) => toValue(item, toString))
.join('');
}
exports.stringifyContent = stringifyContent;
// TODO This is really a workaround, and not super reliable
// For now we only support serializing tagName, className and content
// Can we implement the TOC with real JSX nodes instead of html strings later?
function mdxJsxTextElementToHtml(element, toString) {
const tag = element.name;
const attributes = element.attributes.filter((child) => child.type === 'mdxJsxAttribute');
const classAttribute = attributes.find((attr) => attr.name === 'className') ??
attributes.find((attr) => attr.name === 'class');
const classAttributeString = classAttribute
? `class="${(0, escape_html_1.default)(String(classAttribute.value))}"`
: ``;
const allAttributes = classAttributeString ? ` ${classAttributeString}` : '';
const content = stringifyContent(element, toString);
return `<${tag}${allAttributes}>${content}</${tag}>`;
}
function toValue(node, toString) {
switch (node.type) {
case 'mdxJsxTextElement': {
return mdxJsxTextElementToHtml(node, toString);
}
case 'text':
return (0, escape_html_1.default)(node.value);
case 'heading':
return stringifyContent(node, toString);
case 'inlineCode':
return `<code>${(0, escape_html_1.default)(node.value)}</code>`;
case 'emphasis':
return `<em>${stringifyContent(node, toString)}</em>`;
case 'strong':
return `<strong>${stringifyContent(node, toString)}</strong>`;
case 'delete':
return `<del>${stringifyContent(node, toString)}</del>`;
case 'link':
return stringifyContent(node, toString);
default:
return toString(node);
}
}
exports.toValue = toValue;
function assetRequireAttributeValue(requireString, hash) {
return {
type: 'mdxJsxAttributeValueExpression',
value: `require("${requireString}").default${hash && ` + '${hash}'`}`,
data: {
estree: {
type: 'Program',
body: [
{
type: 'ExpressionStatement',
expression: {
type: 'BinaryExpression',
left: {
type: 'MemberExpression',
object: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'require',
},
arguments: [
{
type: 'Literal',
value: requireString,
raw: `"${requireString}"`,
},
],
optional: false,
},
property: {
type: 'Identifier',
name: 'default',
},
computed: false,
optional: false,
},
operator: '+',
right: {
type: 'Literal',
value: hash,
raw: `"${hash}"`,
},
},
},
],
sourceType: 'module',
comments: [],
},
},
};
}
exports.assetRequireAttributeValue = assetRequireAttributeValue;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/utils/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,sEAAqC;AAUrC;;;;;GAKG;AACH,SAAgB,aAAa,CAC3B,IAAU,EACV,OAAgB;IAEhB,MAAM,CAAC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