@copepod/unified-plugins 0.9.0-dev.2 → 0.9.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -0
- package/dist/index.mjs +46 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,14 @@ interface BaselineOptions {
|
|
|
37
37
|
links?: LinkOptions | undefined;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* @file Process fenced code blocks in Markdown files.
|
|
42
|
+
*
|
|
43
|
+
* 1. Route code blocks to components based on the 'language' attribute.
|
|
44
|
+
* 2. Add breakpoints based on the maximum line length.
|
|
45
|
+
* 3. Route unregistered languages to a default component if specified.
|
|
46
|
+
*/
|
|
47
|
+
|
|
40
48
|
interface FencesOptions {
|
|
41
49
|
/**
|
|
42
50
|
* Default component name if no route is found.
|
package/dist/index.mjs
CHANGED
|
@@ -420,6 +420,22 @@ function baseline2(options = {}) {
|
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
// src/remark/fences.ts
|
|
423
|
+
function makeElement(code, component, attributes) {
|
|
424
|
+
return {
|
|
425
|
+
type: "mdxJsxFlowElement",
|
|
426
|
+
name: component,
|
|
427
|
+
attributes: Object.entries(attributes).map(([name, value]) => ({
|
|
428
|
+
type: "mdxJsxAttribute",
|
|
429
|
+
name,
|
|
430
|
+
value
|
|
431
|
+
})),
|
|
432
|
+
children: [],
|
|
433
|
+
position: code.position,
|
|
434
|
+
data: {
|
|
435
|
+
...code.data
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
}
|
|
423
439
|
function fences(options = {}) {
|
|
424
440
|
const { defaultComponent } = options;
|
|
425
441
|
const componentRoutes = options.componentRoutes ?? {};
|
|
@@ -427,47 +443,6 @@ function fences(options = {}) {
|
|
|
427
443
|
return function plugin(root) {
|
|
428
444
|
const queue = [];
|
|
429
445
|
let parent;
|
|
430
|
-
queue.push(root);
|
|
431
|
-
while (parent = queue.shift()) {
|
|
432
|
-
for (const [index, child] of parent.children.entries()) {
|
|
433
|
-
if (child.type !== "code") {
|
|
434
|
-
continue;
|
|
435
|
-
}
|
|
436
|
-
const { lang, meta, data: oldData = {}, value } = child;
|
|
437
|
-
const component = lang ? componentRoutes[lang] : defaultComponent;
|
|
438
|
-
if (!component) {
|
|
439
|
-
continue;
|
|
440
|
-
}
|
|
441
|
-
const metaTokens = meta?.split(" ") ?? [];
|
|
442
|
-
if (metaTokens.includes("source")) {
|
|
443
|
-
child.meta = metaTokens.filter((token) => token !== "source").join(" ");
|
|
444
|
-
continue;
|
|
445
|
-
}
|
|
446
|
-
const mdx = {
|
|
447
|
-
type: "mdxJsxFlowElement",
|
|
448
|
-
name: component,
|
|
449
|
-
attributes: [
|
|
450
|
-
{
|
|
451
|
-
type: "mdxJsxAttribute",
|
|
452
|
-
name: "meta",
|
|
453
|
-
value: meta ?? ""
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
type: "mdxJsxAttribute",
|
|
457
|
-
name: "source",
|
|
458
|
-
value
|
|
459
|
-
}
|
|
460
|
-
],
|
|
461
|
-
children: [],
|
|
462
|
-
position: child.position,
|
|
463
|
-
data: {
|
|
464
|
-
...oldData
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
parent.children[index] = mdx;
|
|
468
|
-
}
|
|
469
|
-
queue.push(...onlyParents2(parent.children));
|
|
470
|
-
}
|
|
471
446
|
if (breakpoints.length) {
|
|
472
447
|
queue.push(root);
|
|
473
448
|
while (parent = queue.shift()) {
|
|
@@ -477,8 +452,10 @@ function fences(options = {}) {
|
|
|
477
452
|
}
|
|
478
453
|
const { data = {}, value } = child;
|
|
479
454
|
const maxLength = value.split("\n").map((line) => line.length).reduce((max, len) => Math.max(max, len), 0);
|
|
455
|
+
let match = 0;
|
|
480
456
|
for (const [length, breakpoint] of breakpoints) {
|
|
481
|
-
if (maxLength >= length) {
|
|
457
|
+
if (maxLength >= length && length > match) {
|
|
458
|
+
match = length;
|
|
482
459
|
child.data = {
|
|
483
460
|
...data,
|
|
484
461
|
hProperties: {
|
|
@@ -486,13 +463,39 @@ function fences(options = {}) {
|
|
|
486
463
|
"data-breakpoint": breakpoint
|
|
487
464
|
}
|
|
488
465
|
};
|
|
489
|
-
break;
|
|
490
466
|
}
|
|
491
467
|
}
|
|
492
468
|
}
|
|
493
469
|
queue.push(...onlyParents2(parent.children));
|
|
494
470
|
}
|
|
495
471
|
}
|
|
472
|
+
queue.push(root);
|
|
473
|
+
while (parent = queue.shift()) {
|
|
474
|
+
for (const [index, child] of parent.children.entries()) {
|
|
475
|
+
if (child.type !== "code") {
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
const { lang, meta, value, data } = child;
|
|
479
|
+
const { hProperties = {} } = data ?? {};
|
|
480
|
+
const breakpoint = hProperties["data-breakpoint"] ?? null;
|
|
481
|
+
const component = lang ? componentRoutes[lang] : defaultComponent;
|
|
482
|
+
if (!component) {
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
const metaTokens = meta?.split(" ") ?? [];
|
|
486
|
+
if (metaTokens.includes("source")) {
|
|
487
|
+
child.meta = metaTokens.filter((token) => token !== "source").join(" ");
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
const mdx = makeElement(child, component, {
|
|
491
|
+
meta: meta ?? "",
|
|
492
|
+
source: value,
|
|
493
|
+
breakpoint
|
|
494
|
+
});
|
|
495
|
+
parent.children[index] = mdx;
|
|
496
|
+
}
|
|
497
|
+
queue.push(...onlyParents2(parent.children));
|
|
498
|
+
}
|
|
496
499
|
};
|
|
497
500
|
}
|
|
498
501
|
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/rehype/index.ts","../src/rehype/utils.ts","../src/rehype/transforms/paragraphs.ts","../src/rehype/baseline.ts","../src/remark/index.ts","../src/remark/baseline.ts","../src/remark/transforms/asides.ts","../src/remark/transforms/captions.ts","../src/remark/transforms/figures.ts","../src/remark/utils.ts","../src/remark/transforms/loners/links/codepen.ts","../src/remark/transforms/loners/links/youtube.ts","../src/remark/transforms/loners/links/index.ts","../src/remark/transforms/loners/index.ts","../src/remark/fences.ts"],"sourcesContent":["import type { Root } from 'hast'\nimport type { Options as KatexOptions } from 'rehype-katex'\nimport katex from 'rehype-katex'\nimport { baseline, type BaselineOptions } from './baseline'\n\nexport interface PresetOptions {\n\tbaseline?: BaselineOptions | undefined\n\tkatex?: KatexOptions | undefined\n}\n\ninterface Options { [key: string]: any }\ntype Factory = (options: Options) => (root: Root) => void\n\nexport function plugins(options: PresetOptions = {}) {\n\treturn [\n\t\t[katex, options.katex ?? {}],\n\t\t[baseline, options.baseline ?? {}],\n\t] as [Factory, Options][]\n}\n","import type * as hast from 'hast'\n\nexport function nodeToString(node: hast.Node): string {\n\tif ('value' in node && typeof node.value === 'string') {\n\t\treturn node.value.trim()\n\t}\n\n\tif (isParent(node)) {\n\t\treturn node.children.map(nodeToString).join(' ').replace(/\\s+/g, ' ')\n\t}\n\n\treturn ''\n}\n\nexport function onlyParents(nodes: hast.Node[]): hast.Parent[] {\n\treturn nodes.filter(node => isParent(node)) as hast.Parent[]\n}\n\nexport function isParent(node: hast.Node): node is hast.Parent {\n\treturn 'children' in node && Array.isArray(node.children) && node.children.length > 0\n}\n\nexport function isElement(node: hast.Node | undefined, withName: string | RegExp | undefined = undefined): node is hast.Element {\n\tconst element = node as hast.Element\n\tconst name = element?.type === 'element' && element.tagName\n\n\tif (typeof name !== 'string') {\n\t\treturn false\n\t}\n\n\tif (withName instanceof RegExp) {\n\t\treturn withName.test(name)\n\t}\n\telse if (typeof withName === 'string') {\n\t\treturn name === withName\n\t}\n\n\treturn true\n}\n","import type { ElementContent, Node, Parent, Text } from 'hast'\nimport { isElement, nodeToString } from '../utils'\n\nexport function paragraphs(parent: Parent) {\n\tconst children: Node[] = []\n\tfor (const child of parent.children) {\n\t\tif (isElement(child, 'p')) {\n\t\t\t// Skip empty paragraphs\n\t\t\tif (child.children.length === 0) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Trim start\n\t\t\tlet text = child.children[0] as Text\n\t\t\tif (text.type === 'text') {\n\t\t\t\ttext.value = text.value.trimStart()\n\t\t\t}\n\n\t\t\t// Trim end\n\t\t\ttext = child.children[child.children.length - 1] as Text\n\t\t\tif (text.type === 'text') {\n\t\t\t\ttext.value = text.value.trimEnd()\n\t\t\t}\n\n\t\t\t// Skip empty text paragraphs\n\t\t\tconst hasNonText = child.children.some(child => child.type !== 'text')\n\t\t\tconst isEmpty = !hasNonText && nodeToString(child).trim() === ''\n\t\t\tif (isEmpty) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\t// Accept node\n\t\tchildren.push(child)\n\t}\n\n\tparent.children = children as ElementContent[]\n}\n","import type { Parent, Root, Text } from 'hast'\nimport * as transforms from './transforms'\nimport { isElement, onlyParents } from './utils'\n\nexport interface BaselineOptions {\n}\n\nexport function baseline(_options: BaselineOptions = {}) {\n\treturn function plugin(root: Root) {\n\t\tconst queue: Array<Parent> = []\n\t\tlet parent: Parent | undefined\n\n\t\t// First pass:\n\t\t// 1. Trim paragraphs.\n\t\t// 2. Remove empty paragraphs.\n\t\tqueue.push(root)\n\t\t// eslint-disable-next-line no-cond-assign\n\t\twhile (parent = queue.shift()) {\n\t\t\ttransforms.paragraphs(parent)\n\n\t\t\tqueue.push(...onlyParents(parent.children))\n\t\t}\n\n\t\t// Second pass:\n\t\t// 1. Remove lone newlines from all nodes that aren't inside `<code>` or `<pre>`.\n\t\tqueue.push(root)\n\t\t// eslint-disable-next-line no-cond-assign\n\t\twhile (parent = queue.shift()) {\n\t\t\tif (isElement(parent, /^code|pre$/)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tparent.children = parent.children.filter(node =>\n\t\t\t\tnode.type !== 'text' || (node as Text).value !== '\\n',\n\t\t\t)\n\n\t\t\tqueue.push(...onlyParents(parent.children))\n\t\t}\n\t}\n}\n","import type { Root } from 'mdast'\nimport type { Options as MathOptions } from 'remark-math'\nimport math from 'remark-math'\nimport { baseline, type BaselineOptions } from './baseline'\nimport { fences, type FencesOptions } from './fences'\n\nexport interface PresetOptions {\n\tbaseline?: BaselineOptions | undefined\n\tmath?: MathOptions | undefined\n\tfences?: FencesOptions | undefined\n}\n\ninterface Options { [key: string]: any }\ntype Factory = (options: Options) => (root: Root) => void\n\nexport function plugins(options: PresetOptions = {}) {\n\treturn [\n\t\t[fences, options.fences ?? {}],\n\t\t[math, options.math ?? {}],\n\t\t[baseline, options.baseline ?? {}],\n\t] as [Factory, Options][]\n}\n","import type { Parent, Root } from 'mdast'\nimport type { LinkOptions } from './transforms/loners/links'\nimport GithubSlugger from 'github-slugger'\nimport * as transforms from './transforms'\nimport * as utils from './utils'\n\nconst SLUGGER = new GithubSlugger()\n\nexport interface BaselineOptions {\n\tlinks?: LinkOptions | undefined\n}\n\nexport function baseline(options: BaselineOptions = {}) {\n\treturn function plugin(root: Root) {\n\t\tSLUGGER.reset()\n\n\t\tconst queue: Array<Parent> = []\n\t\tlet parent: Parent | undefined\n\n\t\tqueue.push(root)\n\t\t// eslint-disable-next-line no-cond-assign\n\t\twhile (parent = queue.shift()) {\n\t\t\ttransforms.asides(parent)\n\t\t\ttransforms.captions(parent)\n\t\t\ttransforms.loners(parent, options.links ?? {})\n\t\t\tqueue.push(...utils.onlyParents(parent.children))\n\t\t}\n\n\t\tqueue.push(root)\n\t\t// eslint-disable-next-line no-cond-assign\n\t\twhile (parent = queue.shift()) {\n\t\t\ttransforms.figures(parent)\n\t\t\tqueue.push(...utils.onlyParents(parent.children))\n\t\t}\n\t}\n}\n","import type { Data, Paragraph, Parent, Text } from 'mdast'\nimport type { AnyData } from '../utils'\n\n/**\n * Support for asides.\n *\n * ```md\n * > [!NOTE: This is a note]\n * > This is the content of the note.\n *\n * > [!WARNING]\n * > This is a warning.\n * ```\n */\nexport function asides(parent: Parent) {\n\tif (parent.type !== 'blockquote' || parent.children[0]?.type !== 'paragraph') {\n\t\treturn\n\t}\n\n\tconst paragraph = parent.children[0] as Paragraph\n\tif (paragraph.children[0]?.type !== 'text') {\n\t\treturn\n\t}\n\n\tconst text = paragraph.children[0] as Text\n\n\t// Extract the inner content of [!…]\n\tconst [full, args] = /^\\s*\\[!([^\\]]+)\\]\\s*/.exec(text.value) || []\n\tif (!full || !args) {\n\t\treturn\n\t}\n\n\t// Remove the [!…] from the text\n\t// Note: This has the effect of trimming the start of the paragraph\n\ttext.value = text.value.slice(full.length)\n\n\t// Parse the type and title\n\t// eslint-disable-next-line regexp/no-super-linear-backtracking\n\tconst match = /^\\s*([A-Z][A-Z_]*)(?::\\s+([^\\]]+))?$/.exec(args)\n\tif (!match) {\n\t\treturn\n\t}\n\tconst type = match[1]!.toLowerCase()\n\tconst title = match[2]?.trim() ?? `${match[1]![0]}${type.slice(1).replace(/_/g, ' ')}`\n\tconst { data } = parent as AnyData\n\tparent.data = {\n\t\t...data,\n\t\ttype,\n\t\ttitle,\n\t\thName: 'aside',\n\t\thProperties: {\n\t\t\t...data?.hProperties,\n\t\t\t'className': ['aside', `aside-${type}`],\n\t\t\t'data-type': type,\n\t\t\t'data-title': title,\n\t\t},\n\t} as Data\n}\n","import type { Parent } from 'mdast'\n\n/**\n * Support for captions, using the \"double blockquote\" `>>` syntax.\n */\nexport function captions(parent: Parent) {\n\tif (parent.children[1] || parent.type !== 'blockquote' || parent.children[0]?.type !== 'blockquote') {\n\t\treturn\n\t}\n\n\tparent.data = {\n\t\t...parent.data,\n\t\thName: 'figcaption',\n\t}\n\tparent.children = parent.children[0].children\n}\n","import type { BlockContent, Blockquote, Parent } from 'mdast'\nimport type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx'\nimport type * as utils from '../utils'\n\nexport function figures(parent: Parent) {\n\tconst parentJSX = parent as MdxJsxFlowElement & utils.AnyData\n\n\tlet len = parent.children.length\n\tfor (let i = 0; i < len; i++) {\n\t\tconst child = parent.children[i] as MdxJsxFlowElement & utils.AnyData\n\n\t\t// Wrap <figcaption> elements and their previous sibling in a <figure>\n\t\tif (i > 0\n\t\t\t&& (child.data?.hName === 'figcaption' || (child.type === 'mdxJsxFlowElement' && child.name === 'figcaption'))\n\t\t\t&& !(parentJSX.data?.hName === 'figure' || (parent.type === 'mdxJsxFlowElement' && parentJSX.name === 'figure'))\n\t\t) {\n\t\t\t--len\n\t\t\tconst captioned = parent.children[--i] as BlockContent\n\t\t\tparent.children.splice(i, 2, {\n\t\t\t\ttype: 'blockquote',\n\t\t\t\tdata: {\n\t\t\t\t\thName: 'figure',\n\t\t\t\t},\n\t\t\t\tposition: captioned.position,\n\t\t\t\tchildren: [captioned, child],\n\t\t\t} satisfies Blockquote)\n\t\t}\n\t}\n}\n","import type * as mdast from 'mdast'\nimport type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx'\n\nexport interface AnyData { data?: { [key: string]: any } }\n\nexport function nodeToString(node: mdast.Node): string {\n\tif ('value' in node && typeof node.value === 'string') {\n\t\treturn node.value.trim()\n\t}\n\n\tif (isParent(node)) {\n\t\treturn node.children.map(nodeToString).join(' ').replace(/\\s+/g, ' ')\n\t}\n\n\treturn ''\n}\n\nexport function onlyParents(nodes: mdast.Node[]): mdast.Parent[] {\n\treturn nodes.filter(node => isParent(node)) as mdast.Parent[]\n}\n\nexport function isParent(node: mdast.Node | undefined | null): node is mdast.Parent {\n\treturn node !== undefined\n\t\t&& node !== null\n\t\t&& 'children' in node\n\t\t&& Array.isArray(node.children)\n\t\t&& node.children[0] !== undefined\n\t\t&& !isMdxJsxFlowElement(node)\n\t\t&& !isMdxJsxTextElement(node)\n}\n\nexport function isLink(node: mdast.Node | undefined | null): node is mdast.Link {\n\treturn node?.type === 'link'\n}\n\nexport function isParagraph(node: mdast.Node | undefined | null): node is mdast.Paragraph {\n\treturn node?.type === 'paragraph'\n}\n\nexport function isText(node: mdast.Node | undefined | null): node is mdast.Text {\n\treturn node?.type === 'text'\n}\n\nexport function isMdxJsxFlowElement(node: mdast.Node | undefined | null): node is MdxJsxFlowElement {\n\treturn node?.type === 'mdxJsxFlowElement'\n}\n\nexport function isMdxJsxTextElement(node: mdast.Node | undefined | null): node is MdxJsxTextElement {\n\treturn node?.type === 'mdxJsxTextElement'\n}\n","import type { Link, Parent } from 'mdast'\nimport type { LinkTransform } from './transform'\nimport 'mdast-util-to-hast'\n\nexport const codepen: LinkTransform = {\n\tname: 'codepen',\n\tdetect: /^https:\\/\\/codepen\\.io\\/([^/]+)\\/(?:pen|embed|embed\\/preview)\\/([^?/]+)(?:\\?(.+))?/,\n\tgroups: ['owner', 'pen', 'query'],\n\ttransform: function (link: Link, owner: string, pen: string): Parent | undefined {\n\t\tconst url = new URL(link.url)\n\t\turl.pathname = `/${owner}/embed/preview/${pen}`\n\t\tif (!url.searchParams.has('default-tab')) {\n\t\t\turl.searchParams.set('default-tab', 'html,result')\n\t\t}\n\t\treturn {\n\t\t\ttype: 'blockquote',\n\t\t\tposition: link.position,\n\t\t\tchildren: [],\n\t\t\tdata: {\n\t\t\t\thName: 'div',\n\t\t\t\thProperties: {\n\t\t\t\t\tstyle: 'resize:both;overflow:auto;display:flex;min-height:20rem',\n\t\t\t\t},\n\t\t\t\thChildren: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'element',\n\t\t\t\t\t\ttagName: 'iframe',\n\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tsrc: url.href,\n\t\t\t\t\t\t\ttitle: link.title || 'CodePen Embed',\n\t\t\t\t\t\t\tstyle: 'border:0;width:100%;height:100%;min-height:20rem',\n\t\t\t\t\t\t\tframeborder: '0',\n\t\t\t\t\t\t\tscrolling: 'no',\n\t\t\t\t\t\t\tallowfullscreen: true,\n\t\t\t\t\t\t\tallowtransparency: true,\n\t\t\t\t\t\t\tloading: 'lazy',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t} satisfies Parent\n\t} as LinkTransform['transform'],\n}\n","import type { Link, Parent } from 'mdast'\nimport type { LinkTransform } from './transform'\n\nexport const youtube: LinkTransform = {\n\tname: 'youtube',\n\tdetect: /^https:\\/\\/(?:youtu\\.be\\/|(?:.+\\.)?youtube\\.com\\/watch\\?(?:[^&]+&)*v=)([^?&/]+)(?:[?&](.+))?/,\n\tgroups: ['id', 'query'],\n\ttransform: function (link: Link, id: string): Parent | undefined {\n\t\tconst url = new URL(link.url)\n\t\tconst t = url.searchParams.get('t')\n\t\tif (t) {\n\t\t\turl.searchParams.set('start', t)\n\t\t\turl.searchParams.delete('t')\n\t\t}\n\t\turl.hostname = 'www.youtube-nocookie.com'\n\t\turl.pathname = `/embed/${id}`\n\n\t\tconst element = {\n\t\t\ttype: 'image',\n\t\t\turl: url.href,\n\t\t\ttitle: link.title || 'YouTube video player',\n\t\t\tposition: link.position,\n\t\t\tchildren: [],\n\t\t\tdata: {\n\t\t\t\thName: 'iframe',\n\t\t\t\thProperties: {\n\t\t\t\t\twidth: '560',\n\t\t\t\t\theight: '315',\n\t\t\t\t\tstyle: 'border:0;width:100%;height:auto;aspect-ratio:16/9',\n\t\t\t\t\tframeborder: '0',\n\t\t\t\t\tallow: 'accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share',\n\t\t\t\t\treferrerpolicy: 'strict-origin-when-cross-origin',\n\t\t\t\t\tallowfullscreen: true,\n\t\t\t\t\tloading: 'lazy',\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\n\t\treturn element\n\t} as LinkTransform['transform'],\n}\n","import type { Link } from 'mdast'\nimport type { MdxJsxFlowElement, MdxJsxFlowElementData } from 'mdast-util-mdx-jsx'\nimport type { LinkTransform } from './transform'\nimport { nodeToString } from '../../../utils'\nimport { codepen } from './codepen'\nimport { youtube } from './youtube'\n\nexport * from './codepen'\nexport * from './transform'\nexport * from './youtube'\n\nconst DEFAULT_TRANSFORMS: LinkTransform[] = [\n\tyoutube,\n\tcodepen,\n]\n\nexport interface LinkOptions {\n\treadonly transforms?: LinkTransform[]\n\treadonly defaultComponent?: string | undefined\n\treadonly componentRoutes?: Record<string, string> | undefined\n}\n\nexport function processLink(link: Link, options: LinkOptions) {\n\tfor (const { name, detect, transform, groups } of [\n\t\t...DEFAULT_TRANSFORMS,\n\t\t...options.transforms ?? [],\n\t]) {\n\t\tconst match = detect.exec(link.url)\n\t\tif (!match) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst args = match.slice(1) as Array<string | undefined>\n\n\t\t// Links utually don't have a title, only child nodes.\n\t\tif (!link.title) {\n\t\t\tconst title = nodeToString(link).trim()\n\t\t\tif (title) {\n\t\t\t\tlink.title = title\n\t\t\t}\n\t\t}\n\n\t\t// Replace the link with the transformed node\n\t\tconst component = options.componentRoutes?.[name] ?? options.defaultComponent\n\t\tif (!component) {\n\t\t\treturn transform(link, ...args)\n\t\t}\n\n\t\t// Route the loner to an MDX component, passing not only the url and title as props,\n\t\t// but also all the captured groups from the regex.\n\t\tconst mdx = {\n\t\t\ttype: 'mdxJsxFlowElement',\n\t\t\tname: component,\n\t\t\tchildren: link.children,\n\t\t\tposition: link.position,\n\t\t\tdata: { _mdxExplicitJsx: true } as MdxJsxFlowElementData,\n\t\t\tattributes: [\n\t\t\t\t{\n\t\t\t\t\ttype: 'mdxJsxAttribute',\n\t\t\t\t\tname: 'url',\n\t\t\t\t\tvalue: link.url,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttype: 'mdxJsxAttribute',\n\t\t\t\t\tname: 'args',\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\ttype: 'mdxJsxAttributeValueExpression',\n\t\t\t\t\t\tvalue: `[${args.map(value => value ? JSON.stringify(value) : 'undefined').join(', ')}]`,\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\testree: {\n\t\t\t\t\t\t\t\ttype: 'Program',\n\t\t\t\t\t\t\t\tbody: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'ExpressionStatement',\n\t\t\t\t\t\t\t\t\t\texpression: {\n\t\t\t\t\t\t\t\t\t\t\ttype: 'ArrayExpression',\n\t\t\t\t\t\t\t\t\t\t\telements: args.map(value => value ? { type: 'Literal', value, raw: JSON.stringify(value) } : { type: 'Identifier', name: 'undefined' }),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tsourceType: 'module',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t} as MdxJsxFlowElement\n\n\t\tif (link.title) {\n\t\t\tmdx.attributes.push({\n\t\t\t\ttype: 'mdxJsxAttribute',\n\t\t\t\tname: 'title',\n\t\t\t\tvalue: link.title,\n\t\t\t})\n\t\t}\n\n\t\t// If the transform names any group, pass them as props\n\t\tfor (const [index, name] of groups?.entries() ?? []) {\n\t\t\tconst value = args[index]\n\t\t\tif (typeof name === 'string' && typeof value === 'string') {\n\t\t\t\tmdx.attributes.push({ type: 'mdxJsxAttribute', name, value })\n\t\t\t}\n\t\t}\n\n\t\treturn mdx\n\t}\n\n\treturn undefined\n}\n","import type { Parent, PhrasingContent, RootContent } from 'mdast'\nimport { isLink } from '../../utils'\nimport { type LinkOptions, type LinkTransform, processLink } from './links'\nimport 'mdast-util-to-hast'\n\nconst LONERS_MD = new Set(['image'])\nconst LONERS_MDX = new Set([\n\t'iframe',\n\t'img',\n\t'figcaption',\n\t'picture',\n\t'video',\n])\n\nexport type { LinkTransform }\n\nexport function loners(parent: Parent, options: LinkOptions = {}): void {\n\tfor (const [index, child] of parent.children.entries()) {\n\t\tif (child.type === 'paragraph' && child.children[0] && !child.children[1]) {\n\t\t\t// This paragraph has only one child\n\t\t\tconst loner = child.children[0] as PhrasingContent & { name?: string }\n\t\t\tlet replacer: Parent | undefined\n\n\t\t\tif (LONERS_MD.has(loner.type)) {\n\t\t\t\t// Unwrap the loner\n\t\t\t\treplacer = loner as Parent\n\t\t\t}\n\t\t\telse if (/^mdxJsx.+Element$/.test(loner.type) && LONERS_MDX.has(loner.name ?? '')) {\n\t\t\t\t// Unwrap the loner and mark it as a flow element\n\t\t\t\treplacer = {\n\t\t\t\t\t...loner,\n\t\t\t\t\ttype: 'mdxJsxFlowElement',\n\t\t\t\t} as Parent\n\t\t\t}\n\t\t\telse if (isLink(loner)) {\n\t\t\t\treplacer = processLink(loner, options)\n\t\t\t}\n\n\t\t\tif (replacer) {\n\t\t\t\tparent.children[index] = replacer as RootContent\n\t\t\t}\n\t\t}\n\t}\n}\n","/*\n Route code blocks to components based on the 'language' attribute.\n */\nimport type { Code, Parent, Root } from 'mdast'\nimport type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx-jsx'\nimport { onlyParents } from './utils'\n\nexport interface FencesOptions {\n\t/**\n\t * Default component name if no route is found.\n\t */\n\treadonly defaultComponent?: string | undefined\n\n\t/**\n\t * A map of language to MDX component name.\n\t */\n\treadonly componentRoutes?: Record<string, string> | undefined\n\n\t/**\n\t * Breakpoints for code blocks based on the maximum line length.\n\t */\n\treadonly breakpoints?: [number, string][] | undefined\n}\n\nexport function fences(options: FencesOptions = {}) {\n\tconst { defaultComponent } = options\n\tconst componentRoutes = options.componentRoutes ?? {}\n\tconst breakpoints = (options.breakpoints ?? []).toSorted((a, b) => b[0] - a[0])\n\n\treturn function plugin(root: Root) {\n\t\tconst queue: Array<Parent> = []\n\t\tlet parent: Parent | undefined\n\n\t\t// First pass: Replace code blocks with components.\n\t\tqueue.push(root)\n\t\t// eslint-disable-next-line no-cond-assign\n\t\twhile (parent = queue.shift()) {\n\t\t\tfor (const [index, child] of parent.children.entries()) {\n\t\t\t\tif (child.type !== 'code') {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst { lang, meta, data: oldData = {}, value } = child as Code\n\n\t\t\t\t// If no component is registered for the language, skip.\n\t\t\t\tconst component = lang ? componentRoutes[lang] : defaultComponent\n\t\t\t\tif (!component) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t// If the meta string has `source`, skip.\n\t\t\t\tconst metaTokens = meta?.split(' ') ?? []\n\t\t\t\tif (metaTokens.includes('source')) {\n\t\t\t\t\tchild.meta = metaTokens.filter(token => token !== 'source').join(' ')\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tconst mdx = {\n\t\t\t\t\ttype: 'mdxJsxFlowElement',\n\t\t\t\t\tname: component,\n\t\t\t\t\tattributes: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'mdxJsxAttribute',\n\t\t\t\t\t\t\tname: 'meta',\n\t\t\t\t\t\t\tvalue: meta ?? '',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'mdxJsxAttribute',\n\t\t\t\t\t\t\tname: 'source',\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t},\n\t\t\t\t\t] satisfies MdxJsxAttribute[],\n\t\t\t\t\tchildren: [],\n\t\t\t\t\tposition: child.position,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t...oldData,\n\t\t\t\t\t},\n\t\t\t\t} as MdxJsxFlowElement\n\t\t\t\tparent.children[index] = mdx\n\t\t\t}\n\n\t\t\tqueue.push(...onlyParents(parent.children))\n\t\t}\n\n\t\t// Second pass: Add breakpoints to code blocks.\n\t\tif (breakpoints.length) {\n\t\t\tqueue.push(root)\n\t\t\t// eslint-disable-next-line no-cond-assign\n\t\t\twhile (parent = queue.shift()) {\n\t\t\t\tfor (const child of parent.children) {\n\t\t\t\t\tif (child.type !== 'code') {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst { data = {}, value } = child as Code\n\n\t\t\t\t\t// Count characters per line and set breakpoints\n\t\t\t\t\tconst maxLength = value.split('\\n').map(line => line.length).reduce((max, len) => Math.max(max, len), 0)\n\t\t\t\t\tfor (const [length, breakpoint] of breakpoints) {\n\t\t\t\t\t\tif (maxLength >= length) {\n\t\t\t\t\t\t\tchild.data = {\n\t\t\t\t\t\t\t\t...data,\n\t\t\t\t\t\t\t\thProperties: {\n\t\t\t\t\t\t\t\t\t...data?.hProperties,\n\t\t\t\t\t\t\t\t\t'data-breakpoint': breakpoint,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tqueue.push(...onlyParents(parent.children))\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAEA,OAAO,WAAW;;;ACAX,SAAS,aAAa,MAAyB;AACrD,MAAI,WAAW,QAAQ,OAAO,KAAK,UAAU,UAAU;AACtD,WAAO,KAAK,MAAM,KAAK;AAAA,EACxB;AAEA,MAAI,SAAS,IAAI,GAAG;AACnB,WAAO,KAAK,SAAS,IAAI,YAAY,EAAE,KAAK,GAAG,EAAE,QAAQ,QAAQ,GAAG;AAAA,EACrE;AAEA,SAAO;AACR;AAEO,SAAS,YAAY,OAAmC;AAC9D,SAAO,MAAM,OAAO,UAAQ,SAAS,IAAI,CAAC;AAC3C;AAEO,SAAS,SAAS,MAAsC;AAC9D,SAAO,cAAc,QAAQ,MAAM,QAAQ,KAAK,QAAQ,KAAK,KAAK,SAAS,SAAS;AACrF;AAEO,SAAS,UAAU,MAA6B,WAAwC,QAAiC;AAC/H,QAAM,UAAU;AAChB,QAAM,OAAO,SAAS,SAAS,aAAa,QAAQ;AAEpD,MAAI,OAAO,SAAS,UAAU;AAC7B,WAAO;AAAA,EACR;AAEA,MAAI,oBAAoB,QAAQ;AAC/B,WAAO,SAAS,KAAK,IAAI;AAAA,EAC1B,WACS,OAAO,aAAa,UAAU;AACtC,WAAO,SAAS;AAAA,EACjB;AAEA,SAAO;AACR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AAAA,IAC3C;AAGA,QAAI,YAAY,QAAQ;AACvB,YAAM,KAAK,IAAI;AAEf,aAAO,SAAS,MAAM,MAAM,GAAG;AAC9B,mBAAW,SAAS,OAAO,UAAU;AACpC,cAAI,MAAM,SAAS,QAAQ;AAC1B;AAAA,UACD;AACA,gBAAM,EAAE,OAAO,CAAC,GAAG,MAAM,IAAI;AAG7B,gBAAM,YAAY,MAAM,MAAM,IAAI,EAAE,IAAI,UAAQ,KAAK,MAAM,EAAE,OAAO,CAAC,KAAK,QAAQ,KAAK,IAAI,KAAK,GAAG,GAAG,CAAC;AACvG,qBAAW,CAAC,QAAQ,UAAU,KAAK,aAAa;AAC/C,gBAAI,aAAa,QAAQ;AACxB,oBAAM,OAAO;AAAA,gBACZ,GAAG;AAAA,gBACH,aAAa;AAAA,kBACZ,GAAG,MAAM;AAAA,kBACT,mBAAmB;AAAA,gBACpB;AAAA,cACD;AACA;AAAA,YACD;AAAA,UACD;AAAA,QACD;AACA,cAAM,KAAK,GAAGA,aAAY,OAAO,QAAQ,CAAC;AAAA,MAC3C;AAAA,IACD;AAAA,EACD;AACD;;;AVlGO,SAASC,SAAQ,UAAyB,CAAC,GAAG;AACpD,SAAO;AAAA,IACN,CAAC,QAAQ,QAAQ,UAAU,CAAC,CAAC;AAAA,IAC7B,CAAC,MAAM,QAAQ,QAAQ,CAAC,CAAC;AAAA,IACzB,CAACC,WAAU,QAAQ,YAAY,CAAC,CAAC;AAAA,EAClC;AACD;","names":["child","plugins","nodeToString","isParent","onlyParents","nodeToString","name","baseline","onlyParents","onlyParents","plugins","baseline"]}
|
|
1
|
+
{"version":3,"sources":["../src/rehype/index.ts","../src/rehype/utils.ts","../src/rehype/transforms/paragraphs.ts","../src/rehype/baseline.ts","../src/remark/index.ts","../src/remark/baseline.ts","../src/remark/transforms/asides.ts","../src/remark/transforms/captions.ts","../src/remark/transforms/figures.ts","../src/remark/utils.ts","../src/remark/transforms/loners/links/codepen.ts","../src/remark/transforms/loners/links/youtube.ts","../src/remark/transforms/loners/links/index.ts","../src/remark/transforms/loners/index.ts","../src/remark/fences.ts"],"sourcesContent":["import type { Root } from 'hast'\nimport type { Options as KatexOptions } from 'rehype-katex'\nimport katex from 'rehype-katex'\nimport { baseline, type BaselineOptions } from './baseline'\n\nexport interface PresetOptions {\n\tbaseline?: BaselineOptions | undefined\n\tkatex?: KatexOptions | undefined\n}\n\ninterface Options { [key: string]: any }\ntype Factory = (options: Options) => (root: Root) => void\n\nexport function plugins(options: PresetOptions = {}) {\n\treturn [\n\t\t[katex, options.katex ?? {}],\n\t\t[baseline, options.baseline ?? {}],\n\t] as [Factory, Options][]\n}\n","import type * as hast from 'hast'\n\nexport function nodeToString(node: hast.Node): string {\n\tif ('value' in node && typeof node.value === 'string') {\n\t\treturn node.value.trim()\n\t}\n\n\tif (isParent(node)) {\n\t\treturn node.children.map(nodeToString).join(' ').replace(/\\s+/g, ' ')\n\t}\n\n\treturn ''\n}\n\nexport function onlyParents(nodes: hast.Node[]): hast.Parent[] {\n\treturn nodes.filter(node => isParent(node)) as hast.Parent[]\n}\n\nexport function isParent(node: hast.Node): node is hast.Parent {\n\treturn 'children' in node && Array.isArray(node.children) && node.children.length > 0\n}\n\nexport function isElement(node: hast.Node | undefined, withName: string | RegExp | undefined = undefined): node is hast.Element {\n\tconst element = node as hast.Element\n\tconst name = element?.type === 'element' && element.tagName\n\n\tif (typeof name !== 'string') {\n\t\treturn false\n\t}\n\n\tif (withName instanceof RegExp) {\n\t\treturn withName.test(name)\n\t}\n\telse if (typeof withName === 'string') {\n\t\treturn name === withName\n\t}\n\n\treturn true\n}\n","import type { ElementContent, Node, Parent, Text } from 'hast'\nimport { isElement, nodeToString } from '../utils'\n\nexport function paragraphs(parent: Parent) {\n\tconst children: Node[] = []\n\tfor (const child of parent.children) {\n\t\tif (isElement(child, 'p')) {\n\t\t\t// Skip empty paragraphs\n\t\t\tif (child.children.length === 0) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Trim start\n\t\t\tlet text = child.children[0] as Text\n\t\t\tif (text.type === 'text') {\n\t\t\t\ttext.value = text.value.trimStart()\n\t\t\t}\n\n\t\t\t// Trim end\n\t\t\ttext = child.children[child.children.length - 1] as Text\n\t\t\tif (text.type === 'text') {\n\t\t\t\ttext.value = text.value.trimEnd()\n\t\t\t}\n\n\t\t\t// Skip empty text paragraphs\n\t\t\tconst hasNonText = child.children.some(child => child.type !== 'text')\n\t\t\tconst isEmpty = !hasNonText && nodeToString(child).trim() === ''\n\t\t\tif (isEmpty) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\t// Accept node\n\t\tchildren.push(child)\n\t}\n\n\tparent.children = children as ElementContent[]\n}\n","import type { Parent, Root, Text } from 'hast'\nimport * as transforms from './transforms'\nimport { isElement, onlyParents } from './utils'\n\nexport interface BaselineOptions {\n}\n\nexport function baseline(_options: BaselineOptions = {}) {\n\treturn function plugin(root: Root) {\n\t\tconst queue: Array<Parent> = []\n\t\tlet parent: Parent | undefined\n\n\t\t// First pass:\n\t\t// 1. Trim paragraphs.\n\t\t// 2. Remove empty paragraphs.\n\t\tqueue.push(root)\n\t\t// eslint-disable-next-line no-cond-assign\n\t\twhile (parent = queue.shift()) {\n\t\t\ttransforms.paragraphs(parent)\n\n\t\t\tqueue.push(...onlyParents(parent.children))\n\t\t}\n\n\t\t// Second pass:\n\t\t// 1. Remove lone newlines from all nodes that aren't inside `<code>` or `<pre>`.\n\t\tqueue.push(root)\n\t\t// eslint-disable-next-line no-cond-assign\n\t\twhile (parent = queue.shift()) {\n\t\t\tif (isElement(parent, /^code|pre$/)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tparent.children = parent.children.filter(node =>\n\t\t\t\tnode.type !== 'text' || (node as Text).value !== '\\n',\n\t\t\t)\n\n\t\t\tqueue.push(...onlyParents(parent.children))\n\t\t}\n\t}\n}\n","import type { Root } from 'mdast'\nimport type { Options as MathOptions } from 'remark-math'\nimport math from 'remark-math'\nimport { baseline, type BaselineOptions } from './baseline'\nimport { fences, type FencesOptions } from './fences'\n\nexport interface PresetOptions {\n\tbaseline?: BaselineOptions | undefined\n\tmath?: MathOptions | undefined\n\tfences?: FencesOptions | undefined\n}\n\ninterface Options { [key: string]: any }\ntype Factory = (options: Options) => (root: Root) => void\n\nexport function plugins(options: PresetOptions = {}) {\n\treturn [\n\t\t[fences, options.fences ?? {}],\n\t\t[math, options.math ?? {}],\n\t\t[baseline, options.baseline ?? {}],\n\t] as [Factory, Options][]\n}\n","import type { Parent, Root } from 'mdast'\nimport type { LinkOptions } from './transforms/loners/links'\nimport GithubSlugger from 'github-slugger'\nimport * as transforms from './transforms'\nimport * as utils from './utils'\n\nconst SLUGGER = new GithubSlugger()\n\nexport interface BaselineOptions {\n\tlinks?: LinkOptions | undefined\n}\n\nexport function baseline(options: BaselineOptions = {}) {\n\treturn function plugin(root: Root) {\n\t\tSLUGGER.reset()\n\n\t\tconst queue: Array<Parent> = []\n\t\tlet parent: Parent | undefined\n\n\t\tqueue.push(root)\n\t\t// eslint-disable-next-line no-cond-assign\n\t\twhile (parent = queue.shift()) {\n\t\t\ttransforms.asides(parent)\n\t\t\ttransforms.captions(parent)\n\t\t\ttransforms.loners(parent, options.links ?? {})\n\t\t\tqueue.push(...utils.onlyParents(parent.children))\n\t\t}\n\n\t\tqueue.push(root)\n\t\t// eslint-disable-next-line no-cond-assign\n\t\twhile (parent = queue.shift()) {\n\t\t\ttransforms.figures(parent)\n\t\t\tqueue.push(...utils.onlyParents(parent.children))\n\t\t}\n\t}\n}\n","import type { Data, Paragraph, Parent, Text } from 'mdast'\nimport type { AnyData } from '../utils'\n\n/**\n * Support for asides.\n *\n * ```md\n * > [!NOTE: This is a note]\n * > This is the content of the note.\n *\n * > [!WARNING]\n * > This is a warning.\n * ```\n */\nexport function asides(parent: Parent) {\n\tif (parent.type !== 'blockquote' || parent.children[0]?.type !== 'paragraph') {\n\t\treturn\n\t}\n\n\tconst paragraph = parent.children[0] as Paragraph\n\tif (paragraph.children[0]?.type !== 'text') {\n\t\treturn\n\t}\n\n\tconst text = paragraph.children[0] as Text\n\n\t// Extract the inner content of [!…]\n\tconst [full, args] = /^\\s*\\[!([^\\]]+)\\]\\s*/.exec(text.value) || []\n\tif (!full || !args) {\n\t\treturn\n\t}\n\n\t// Remove the [!…] from the text\n\t// Note: This has the effect of trimming the start of the paragraph\n\ttext.value = text.value.slice(full.length)\n\n\t// Parse the type and title\n\t// eslint-disable-next-line regexp/no-super-linear-backtracking\n\tconst match = /^\\s*([A-Z][A-Z_]*)(?::\\s+([^\\]]+))?$/.exec(args)\n\tif (!match) {\n\t\treturn\n\t}\n\tconst type = match[1]!.toLowerCase()\n\tconst title = match[2]?.trim() ?? `${match[1]![0]}${type.slice(1).replace(/_/g, ' ')}`\n\tconst { data } = parent as AnyData\n\tparent.data = {\n\t\t...data,\n\t\ttype,\n\t\ttitle,\n\t\thName: 'aside',\n\t\thProperties: {\n\t\t\t...data?.hProperties,\n\t\t\t'className': ['aside', `aside-${type}`],\n\t\t\t'data-type': type,\n\t\t\t'data-title': title,\n\t\t},\n\t} as Data\n}\n","import type { Parent } from 'mdast'\n\n/**\n * Support for captions, using the \"double blockquote\" `>>` syntax.\n */\nexport function captions(parent: Parent) {\n\tif (parent.children[1] || parent.type !== 'blockquote' || parent.children[0]?.type !== 'blockquote') {\n\t\treturn\n\t}\n\n\tparent.data = {\n\t\t...parent.data,\n\t\thName: 'figcaption',\n\t}\n\tparent.children = parent.children[0].children\n}\n","import type { BlockContent, Blockquote, Parent } from 'mdast'\nimport type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx'\nimport type * as utils from '../utils'\n\nexport function figures(parent: Parent) {\n\tconst parentJSX = parent as MdxJsxFlowElement & utils.AnyData\n\n\tlet len = parent.children.length\n\tfor (let i = 0; i < len; i++) {\n\t\tconst child = parent.children[i] as MdxJsxFlowElement & utils.AnyData\n\n\t\t// Wrap <figcaption> elements and their previous sibling in a <figure>\n\t\tif (i > 0\n\t\t\t&& (child.data?.hName === 'figcaption' || (child.type === 'mdxJsxFlowElement' && child.name === 'figcaption'))\n\t\t\t&& !(parentJSX.data?.hName === 'figure' || (parent.type === 'mdxJsxFlowElement' && parentJSX.name === 'figure'))\n\t\t) {\n\t\t\t--len\n\t\t\tconst captioned = parent.children[--i] as BlockContent\n\t\t\tparent.children.splice(i, 2, {\n\t\t\t\ttype: 'blockquote',\n\t\t\t\tdata: {\n\t\t\t\t\thName: 'figure',\n\t\t\t\t},\n\t\t\t\tposition: captioned.position,\n\t\t\t\tchildren: [captioned, child],\n\t\t\t} satisfies Blockquote)\n\t\t}\n\t}\n}\n","import type * as mdast from 'mdast'\nimport type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx'\n\nexport interface AnyData { data?: { [key: string]: any } }\n\nexport function nodeToString(node: mdast.Node): string {\n\tif ('value' in node && typeof node.value === 'string') {\n\t\treturn node.value.trim()\n\t}\n\n\tif (isParent(node)) {\n\t\treturn node.children.map(nodeToString).join(' ').replace(/\\s+/g, ' ')\n\t}\n\n\treturn ''\n}\n\nexport function onlyParents(nodes: mdast.Node[]): mdast.Parent[] {\n\treturn nodes.filter(node => isParent(node)) as mdast.Parent[]\n}\n\nexport function isParent(node: mdast.Node | undefined | null): node is mdast.Parent {\n\treturn node !== undefined\n\t\t&& node !== null\n\t\t&& 'children' in node\n\t\t&& Array.isArray(node.children)\n\t\t&& node.children[0] !== undefined\n\t\t&& !isMdxJsxFlowElement(node)\n\t\t&& !isMdxJsxTextElement(node)\n}\n\nexport function isLink(node: mdast.Node | undefined | null): node is mdast.Link {\n\treturn node?.type === 'link'\n}\n\nexport function isParagraph(node: mdast.Node | undefined | null): node is mdast.Paragraph {\n\treturn node?.type === 'paragraph'\n}\n\nexport function isText(node: mdast.Node | undefined | null): node is mdast.Text {\n\treturn node?.type === 'text'\n}\n\nexport function isMdxJsxFlowElement(node: mdast.Node | undefined | null): node is MdxJsxFlowElement {\n\treturn node?.type === 'mdxJsxFlowElement'\n}\n\nexport function isMdxJsxTextElement(node: mdast.Node | undefined | null): node is MdxJsxTextElement {\n\treturn node?.type === 'mdxJsxTextElement'\n}\n","import type { Link, Parent } from 'mdast'\nimport type { LinkTransform } from './transform'\nimport 'mdast-util-to-hast'\n\nexport const codepen: LinkTransform = {\n\tname: 'codepen',\n\tdetect: /^https:\\/\\/codepen\\.io\\/([^/]+)\\/(?:pen|embed|embed\\/preview)\\/([^?/]+)(?:\\?(.+))?/,\n\tgroups: ['owner', 'pen', 'query'],\n\ttransform: function (link: Link, owner: string, pen: string): Parent | undefined {\n\t\tconst url = new URL(link.url)\n\t\turl.pathname = `/${owner}/embed/preview/${pen}`\n\t\tif (!url.searchParams.has('default-tab')) {\n\t\t\turl.searchParams.set('default-tab', 'html,result')\n\t\t}\n\t\treturn {\n\t\t\ttype: 'blockquote',\n\t\t\tposition: link.position,\n\t\t\tchildren: [],\n\t\t\tdata: {\n\t\t\t\thName: 'div',\n\t\t\t\thProperties: {\n\t\t\t\t\tstyle: 'resize:both;overflow:auto;display:flex;min-height:20rem',\n\t\t\t\t},\n\t\t\t\thChildren: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'element',\n\t\t\t\t\t\ttagName: 'iframe',\n\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tsrc: url.href,\n\t\t\t\t\t\t\ttitle: link.title || 'CodePen Embed',\n\t\t\t\t\t\t\tstyle: 'border:0;width:100%;height:100%;min-height:20rem',\n\t\t\t\t\t\t\tframeborder: '0',\n\t\t\t\t\t\t\tscrolling: 'no',\n\t\t\t\t\t\t\tallowfullscreen: true,\n\t\t\t\t\t\t\tallowtransparency: true,\n\t\t\t\t\t\t\tloading: 'lazy',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t} satisfies Parent\n\t} as LinkTransform['transform'],\n}\n","import type { Link, Parent } from 'mdast'\nimport type { LinkTransform } from './transform'\n\nexport const youtube: LinkTransform = {\n\tname: 'youtube',\n\tdetect: /^https:\\/\\/(?:youtu\\.be\\/|(?:.+\\.)?youtube\\.com\\/watch\\?(?:[^&]+&)*v=)([^?&/]+)(?:[?&](.+))?/,\n\tgroups: ['id', 'query'],\n\ttransform: function (link: Link, id: string): Parent | undefined {\n\t\tconst url = new URL(link.url)\n\t\tconst t = url.searchParams.get('t')\n\t\tif (t) {\n\t\t\turl.searchParams.set('start', t)\n\t\t\turl.searchParams.delete('t')\n\t\t}\n\t\turl.hostname = 'www.youtube-nocookie.com'\n\t\turl.pathname = `/embed/${id}`\n\n\t\tconst element = {\n\t\t\ttype: 'image',\n\t\t\turl: url.href,\n\t\t\ttitle: link.title || 'YouTube video player',\n\t\t\tposition: link.position,\n\t\t\tchildren: [],\n\t\t\tdata: {\n\t\t\t\thName: 'iframe',\n\t\t\t\thProperties: {\n\t\t\t\t\twidth: '560',\n\t\t\t\t\theight: '315',\n\t\t\t\t\tstyle: 'border:0;width:100%;height:auto;aspect-ratio:16/9',\n\t\t\t\t\tframeborder: '0',\n\t\t\t\t\tallow: 'accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share',\n\t\t\t\t\treferrerpolicy: 'strict-origin-when-cross-origin',\n\t\t\t\t\tallowfullscreen: true,\n\t\t\t\t\tloading: 'lazy',\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\n\t\treturn element\n\t} as LinkTransform['transform'],\n}\n","import type { Link } from 'mdast'\nimport type { MdxJsxFlowElement, MdxJsxFlowElementData } from 'mdast-util-mdx-jsx'\nimport type { LinkTransform } from './transform'\nimport { nodeToString } from '../../../utils'\nimport { codepen } from './codepen'\nimport { youtube } from './youtube'\n\nexport * from './codepen'\nexport * from './transform'\nexport * from './youtube'\n\nconst DEFAULT_TRANSFORMS: LinkTransform[] = [\n\tyoutube,\n\tcodepen,\n]\n\nexport interface LinkOptions {\n\treadonly transforms?: LinkTransform[]\n\treadonly defaultComponent?: string | undefined\n\treadonly componentRoutes?: Record<string, string> | undefined\n}\n\nexport function processLink(link: Link, options: LinkOptions) {\n\tfor (const { name, detect, transform, groups } of [\n\t\t...DEFAULT_TRANSFORMS,\n\t\t...options.transforms ?? [],\n\t]) {\n\t\tconst match = detect.exec(link.url)\n\t\tif (!match) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst args = match.slice(1) as Array<string | undefined>\n\n\t\t// Links utually don't have a title, only child nodes.\n\t\tif (!link.title) {\n\t\t\tconst title = nodeToString(link).trim()\n\t\t\tif (title) {\n\t\t\t\tlink.title = title\n\t\t\t}\n\t\t}\n\n\t\t// Replace the link with the transformed node\n\t\tconst component = options.componentRoutes?.[name] ?? options.defaultComponent\n\t\tif (!component) {\n\t\t\treturn transform(link, ...args)\n\t\t}\n\n\t\t// Route the loner to an MDX component, passing not only the url and title as props,\n\t\t// but also all the captured groups from the regex.\n\t\tconst mdx = {\n\t\t\ttype: 'mdxJsxFlowElement',\n\t\t\tname: component,\n\t\t\tchildren: link.children,\n\t\t\tposition: link.position,\n\t\t\tdata: { _mdxExplicitJsx: true } as MdxJsxFlowElementData,\n\t\t\tattributes: [\n\t\t\t\t{\n\t\t\t\t\ttype: 'mdxJsxAttribute',\n\t\t\t\t\tname: 'url',\n\t\t\t\t\tvalue: link.url,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttype: 'mdxJsxAttribute',\n\t\t\t\t\tname: 'args',\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\ttype: 'mdxJsxAttributeValueExpression',\n\t\t\t\t\t\tvalue: `[${args.map(value => value ? JSON.stringify(value) : 'undefined').join(', ')}]`,\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\testree: {\n\t\t\t\t\t\t\t\ttype: 'Program',\n\t\t\t\t\t\t\t\tbody: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'ExpressionStatement',\n\t\t\t\t\t\t\t\t\t\texpression: {\n\t\t\t\t\t\t\t\t\t\t\ttype: 'ArrayExpression',\n\t\t\t\t\t\t\t\t\t\t\telements: args.map(value => value ? { type: 'Literal', value, raw: JSON.stringify(value) } : { type: 'Identifier', name: 'undefined' }),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tsourceType: 'module',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t} as MdxJsxFlowElement\n\n\t\tif (link.title) {\n\t\t\tmdx.attributes.push({\n\t\t\t\ttype: 'mdxJsxAttribute',\n\t\t\t\tname: 'title',\n\t\t\t\tvalue: link.title,\n\t\t\t})\n\t\t}\n\n\t\t// If the transform names any group, pass them as props\n\t\tfor (const [index, name] of groups?.entries() ?? []) {\n\t\t\tconst value = args[index]\n\t\t\tif (typeof name === 'string' && typeof value === 'string') {\n\t\t\t\tmdx.attributes.push({ type: 'mdxJsxAttribute', name, value })\n\t\t\t}\n\t\t}\n\n\t\treturn mdx\n\t}\n\n\treturn undefined\n}\n","import type { Parent, PhrasingContent, RootContent } from 'mdast'\nimport { isLink } from '../../utils'\nimport { type LinkOptions, type LinkTransform, processLink } from './links'\nimport 'mdast-util-to-hast'\n\nconst LONERS_MD = new Set(['image'])\nconst LONERS_MDX = new Set([\n\t'iframe',\n\t'img',\n\t'figcaption',\n\t'picture',\n\t'video',\n])\n\nexport type { LinkTransform }\n\nexport function loners(parent: Parent, options: LinkOptions = {}): void {\n\tfor (const [index, child] of parent.children.entries()) {\n\t\tif (child.type === 'paragraph' && child.children[0] && !child.children[1]) {\n\t\t\t// This paragraph has only one child\n\t\t\tconst loner = child.children[0] as PhrasingContent & { name?: string }\n\t\t\tlet replacer: Parent | undefined\n\n\t\t\tif (LONERS_MD.has(loner.type)) {\n\t\t\t\t// Unwrap the loner\n\t\t\t\treplacer = loner as Parent\n\t\t\t}\n\t\t\telse if (/^mdxJsx.+Element$/.test(loner.type) && LONERS_MDX.has(loner.name ?? '')) {\n\t\t\t\t// Unwrap the loner and mark it as a flow element\n\t\t\t\treplacer = {\n\t\t\t\t\t...loner,\n\t\t\t\t\ttype: 'mdxJsxFlowElement',\n\t\t\t\t} as Parent\n\t\t\t}\n\t\t\telse if (isLink(loner)) {\n\t\t\t\treplacer = processLink(loner, options)\n\t\t\t}\n\n\t\t\tif (replacer) {\n\t\t\t\tparent.children[index] = replacer as RootContent\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * @file Process fenced code blocks in Markdown files.\n *\n * 1. Route code blocks to components based on the 'language' attribute.\n * 2. Add breakpoints based on the maximum line length.\n * 3. Route unregistered languages to a default component if specified.\n */\nimport type { Code, Parent, Root } from 'mdast'\nimport type { MdxJsxAttribute, MdxJsxAttributeValueExpression, MdxJsxFlowElement } from 'mdast-util-mdx-jsx'\nimport { onlyParents } from './utils'\n\nexport interface FencesOptions {\n\t/**\n\t * Default component name if no route is found.\n\t */\n\treadonly defaultComponent?: string | undefined\n\n\t/**\n\t * A map of language to MDX component name.\n\t */\n\treadonly componentRoutes?: Record<string, string> | undefined\n\n\t/**\n\t * Breakpoints for code blocks based on the maximum line length.\n\t */\n\treadonly breakpoints?: [number, string][] | undefined\n}\n\nfunction makeElement(\n\tcode: Code,\n\tcomponent: string,\n\tattributes: Record<string, MdxJsxAttributeValueExpression | string | null>,\n) {\n\treturn {\n\t\ttype: 'mdxJsxFlowElement',\n\t\tname: component,\n\t\tattributes: Object.entries(attributes).map(([name, value]) => ({\n\t\t\ttype: 'mdxJsxAttribute',\n\t\t\tname,\n\t\t\tvalue,\n\t\t} satisfies MdxJsxAttribute)),\n\t\tchildren: [],\n\t\tposition: code.position,\n\t\tdata: {\n\t\t\t...code.data,\n\t\t},\n\t} as MdxJsxFlowElement\n}\n\nexport function fences(options: FencesOptions = {}) {\n\tconst { defaultComponent } = options\n\tconst componentRoutes = options.componentRoutes ?? {}\n\tconst breakpoints = (options.breakpoints ?? []).toSorted((a, b) => b[0] - a[0])\n\n\treturn function plugin(root: Root) {\n\t\tconst queue: Array<Parent> = []\n\t\tlet parent: Parent | undefined\n\n\t\t// First pass: Add breakpoints to code elements.\n\t\tif (breakpoints.length) {\n\t\t\tqueue.push(root)\n\t\t\t// eslint-disable-next-line no-cond-assign\n\t\t\twhile (parent = queue.shift()) {\n\t\t\t\tfor (const child of parent.children) {\n\t\t\t\t\tif (child.type !== 'code') {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst { data = {}, value } = child as Code\n\n\t\t\t\t\t// Count characters per line and set breakpoints\n\t\t\t\t\tconst maxLength = value.split('\\n').map(line => line.length).reduce((max, len) => Math.max(max, len), 0)\n\t\t\t\t\tlet match = 0\n\t\t\t\t\tfor (const [length, breakpoint] of breakpoints) {\n\t\t\t\t\t\tif (maxLength >= length && length > match) {\n\t\t\t\t\t\t\tmatch = length\n\t\t\t\t\t\t\tchild.data = {\n\t\t\t\t\t\t\t\t...data,\n\t\t\t\t\t\t\t\thProperties: {\n\t\t\t\t\t\t\t\t\t...data?.hProperties,\n\t\t\t\t\t\t\t\t\t'data-breakpoint': breakpoint,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tqueue.push(...onlyParents(parent.children))\n\t\t\t}\n\t\t}\n\n\t\t// First pass: Replace code blocks with components.\n\t\tqueue.push(root)\n\t\t// eslint-disable-next-line no-cond-assign\n\t\twhile (parent = queue.shift()) {\n\t\t\tfor (const [index, child] of parent.children.entries()) {\n\t\t\t\tif (child.type !== 'code') {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst { lang, meta, value, data } = child as Code\n\t\t\t\tconst { hProperties = {} } = data ?? {}\n\t\t\t\tconst breakpoint = hProperties['data-breakpoint'] as string | null ?? null\n\n\t\t\t\t// If no component is registered for the language, skip.\n\t\t\t\tconst component = lang ? componentRoutes[lang] : defaultComponent\n\t\t\t\tif (!component) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t// If the meta string has `source`, skip.\n\t\t\t\tconst metaTokens = meta?.split(' ') ?? []\n\t\t\t\tif (metaTokens.includes('source')) {\n\t\t\t\t\tchild.meta = metaTokens.filter(token => token !== 'source').join(' ')\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tconst mdx = makeElement(child, component, {\n\t\t\t\t\tmeta: meta ?? '',\n\t\t\t\t\tsource: value,\n\t\t\t\t\tbreakpoint,\n\t\t\t\t})\n\t\t\t\tparent.children[index] = mdx\n\t\t\t}\n\n\t\t\tqueue.push(...onlyParents(parent.children))\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAEA,OAAO,WAAW;;;ACAX,SAAS,aAAa,MAAyB;AACrD,MAAI,WAAW,QAAQ,OAAO,KAAK,UAAU,UAAU;AACtD,WAAO,KAAK,MAAM,KAAK;AAAA,EACxB;AAEA,MAAI,SAAS,IAAI,GAAG;AACnB,WAAO,KAAK,SAAS,IAAI,YAAY,EAAE,KAAK,GAAG,EAAE,QAAQ,QAAQ,GAAG;AAAA,EACrE;AAEA,SAAO;AACR;AAEO,SAAS,YAAY,OAAmC;AAC9D,SAAO,MAAM,OAAO,UAAQ,SAAS,IAAI,CAAC;AAC3C;AAEO,SAAS,SAAS,MAAsC;AAC9D,SAAO,cAAc,QAAQ,MAAM,QAAQ,KAAK,QAAQ,KAAK,KAAK,SAAS,SAAS;AACrF;AAEO,SAAS,UAAU,MAA6B,WAAwC,QAAiC;AAC/H,QAAM,UAAU;AAChB,QAAM,OAAO,SAAS,SAAS,aAAa,QAAQ;AAEpD,MAAI,OAAO,SAAS,UAAU;AAC7B,WAAO;AAAA,EACR;AAEA,MAAI,oBAAoB,QAAQ;AAC/B,WAAO,SAAS,KAAK,IAAI;AAAA,EAC1B,WACS,OAAO,aAAa,UAAU;AACtC,WAAO,SAAS;AAAA,EAC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;AAAA,gBACpB;AAAA,cACD;AAAA,YACD;AAAA,UACD;AAAA,QACD;AACA,cAAM,KAAK,GAAGC,aAAY,OAAO,QAAQ,CAAC;AAAA,MAC3C;AAAA,IACD;AAGA,UAAM,KAAK,IAAI;AAEf,WAAO,SAAS,MAAM,MAAM,GAAG;AAC9B,iBAAW,CAAC,OAAO,KAAK,KAAK,OAAO,SAAS,QAAQ,GAAG;AACvD,YAAI,MAAM,SAAS,QAAQ;AAC1B;AAAA,QACD;AACA,cAAM,EAAE,MAAM,MAAM,OAAO,KAAK,IAAI;AACpC,cAAM,EAAE,cAAc,CAAC,EAAE,IAAI,QAAQ,CAAC;AACtC,cAAM,aAAa,YAAY,iBAAiB,KAAsB;AAGtE,cAAM,YAAY,OAAO,gBAAgB,IAAI,IAAI;AACjD,YAAI,CAAC,WAAW;AACf;AAAA,QACD;AAGA,cAAM,aAAa,MAAM,MAAM,GAAG,KAAK,CAAC;AACxC,YAAI,WAAW,SAAS,QAAQ,GAAG;AAClC,gBAAM,OAAO,WAAW,OAAO,WAAS,UAAU,QAAQ,EAAE,KAAK,GAAG;AACpE;AAAA,QACD;AAEA,cAAM,MAAM,YAAY,OAAO,WAAW;AAAA,UACzC,MAAM,QAAQ;AAAA,UACd,QAAQ;AAAA,UACR;AAAA,QACD,CAAC;AACD,eAAO,SAAS,KAAK,IAAI;AAAA,MAC1B;AAEA,YAAM,KAAK,GAAGA,aAAY,OAAO,QAAQ,CAAC;AAAA,IAC3C;AAAA,EACD;AACD;;;AV9GO,SAASC,SAAQ,UAAyB,CAAC,GAAG;AACpD,SAAO;AAAA,IACN,CAAC,QAAQ,QAAQ,UAAU,CAAC,CAAC;AAAA,IAC7B,CAAC,MAAM,QAAQ,QAAQ,CAAC,CAAC;AAAA,IACzB,CAACC,WAAU,QAAQ,YAAY,CAAC,CAAC;AAAA,EAClC;AACD;","names":["child","plugins","nodeToString","isParent","onlyParents","nodeToString","name","baseline","onlyParents","onlyParents","plugins","baseline"]}
|