@copepod/unified-plugins 0.5.0 → 0.7.0

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 CHANGED
@@ -37,9 +37,14 @@ interface BaselineOptions {
37
37
  links?: LinkOptions | undefined;
38
38
  }
39
39
 
40
+ interface FencesOptions {
41
+ readonly componentRoutes?: Record<string, string> | undefined;
42
+ }
43
+
40
44
  interface PresetOptions {
41
45
  baseline?: BaselineOptions | undefined;
42
46
  math?: Options$3 | undefined;
47
+ fences?: FencesOptions | undefined;
43
48
  }
44
49
  interface Options {
45
50
  [key: string]: any;
package/dist/index.mjs CHANGED
@@ -194,12 +194,17 @@ function onlyParents2(nodes) {
194
194
  return nodes.filter((node) => isParent2(node));
195
195
  }
196
196
  function isParent2(node) {
197
- const asParent = node ? node : node;
198
- return Array.isArray(asParent?.children) && asParent.children[0] !== void 0;
197
+ return node !== void 0 && node !== null && "children" in node && Array.isArray(node.children) && node.children[0] !== void 0 && !isMdxJsxFlowElement(node) && !isMdxJsxTextElement(node);
199
198
  }
200
199
  function isLink(node) {
201
200
  return node?.type === "link";
202
201
  }
202
+ function isMdxJsxFlowElement(node) {
203
+ return node?.type === "mdxJsxFlowElement";
204
+ }
205
+ function isMdxJsxTextElement(node) {
206
+ return node?.type === "mdxJsxTextElement";
207
+ }
203
208
 
204
209
  // src/remark/transforms/headings.ts
205
210
  function headings(parent, slugger) {
@@ -438,9 +443,60 @@ function baseline2(options = {}) {
438
443
  };
439
444
  }
440
445
 
446
+ // src/remark/fences.ts
447
+ function fences(options = {}) {
448
+ const componentRoutes = options.componentRoutes ?? {};
449
+ return function plugin(root) {
450
+ const queue = [];
451
+ let parent;
452
+ queue.push(root);
453
+ while (parent = queue.shift()) {
454
+ for (const [index, child] of parent.children.entries()) {
455
+ if (child.type !== "code") {
456
+ continue;
457
+ }
458
+ const { lang, meta, data: oldData = {}, value } = child;
459
+ const component = lang && componentRoutes[lang];
460
+ if (!component) {
461
+ continue;
462
+ }
463
+ const metaTokens = meta?.split(" ") ?? [];
464
+ if (metaTokens.includes("source")) {
465
+ child.meta = metaTokens.filter((token) => token !== "source").join(" ");
466
+ continue;
467
+ }
468
+ const mdx = {
469
+ type: "mdxJsxFlowElement",
470
+ name: component,
471
+ attributes: [
472
+ {
473
+ type: "mdxJsxAttribute",
474
+ name: "meta",
475
+ value: meta ?? ""
476
+ },
477
+ {
478
+ type: "mdxJsxAttribute",
479
+ name: "source",
480
+ value
481
+ }
482
+ ],
483
+ children: [],
484
+ position: child.position,
485
+ data: {
486
+ ...oldData
487
+ }
488
+ };
489
+ parent.children[index] = mdx;
490
+ }
491
+ queue.push(...onlyParents2(parent.children));
492
+ }
493
+ };
494
+ }
495
+
441
496
  // src/remark/index.ts
442
497
  function plugins2(options = {}) {
443
498
  return [
499
+ [fences, options.fences ?? {}],
444
500
  [math, options.math ?? {}],
445
501
  [baseline2, options.baseline ?? {}]
446
502
  ];
@@ -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/headings.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"],"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 (node.type === 'text') {\n\t\tconst literal = node as hast.Text\n\t\treturn literal.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'\n\nexport interface PresetOptions {\n\tbaseline?: BaselineOptions | undefined\n\tmath?: MathOptions | 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[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.headings(parent, SLUGGER)\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'\n\nexport interface AnyData { data?: { [key: string]: any } }\n\nexport function nodeToString(node: mdast.Node): string {\n\tif (node.type === 'text') {\n\t\tconst literal = node as mdast.Text\n\t\treturn literal.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\tconst asParent = node ? node as mdast.Parent : node\n\treturn Array.isArray(asParent?.children) && asParent.children[0] !== undefined\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","import type { Link, Parent, PhrasingContent } from 'mdast'\nimport { nodeToString } from '../utils'\n\nexport interface Slugger {\n\tslug: (value: string) => string\n}\n\nexport function headings(parent: Parent, slugger: Slugger) {\n\tif (parent.type !== 'heading' || !parent.children[0]) {\n\t\treturn\n\t}\n\n\tconst slug = slugger.slug(nodeToString(parent))\n\tparent.data = {\n\t\t...parent.data,\n\t\tid: slug,\n\t} as Parent['data']\n\tparent.children = [\n\t\t{\n\t\t\ttype: 'link',\n\t\t\turl: `#${slug}`,\n\t\t\ttitle: null,\n\t\t\tchildren: parent.children as PhrasingContent[],\n\t\t\tposition: parent.position,\n\t\t} satisfies Link,\n\t]\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\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zB,CAACC,WAAU,QAAQ,YAAY,CAAC,CAAC;AAAA,EAClC;AACD;","names":["child","plugins","nodeToString","isParent","onlyParents","nodeToString","nodeToString","name","baseline","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/headings.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 (node.type === 'text') {\n\t\tconst literal = node as hast.Text\n\t\treturn literal.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.headings(parent, SLUGGER)\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 (node.type === 'text') {\n\t\tconst literal = node as mdast.Text\n\t\treturn literal.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, PhrasingContent } from 'mdast'\nimport { nodeToString } from '../utils'\n\nexport interface Slugger {\n\tslug: (value: string) => string\n}\n\nexport function headings(parent: Parent, slugger: Slugger) {\n\tif (parent.type !== 'heading' || !parent.children[0]) {\n\t\treturn\n\t}\n\n\tconst slug = slugger.slug(nodeToString(parent))\n\tparent.data = {\n\t\t...parent.data,\n\t\tid: slug,\n\t} as Parent['data']\n\tparent.children = [\n\t\t{\n\t\t\ttype: 'link',\n\t\t\turl: `#${slug}`,\n\t\t\ttitle: null,\n\t\t\tchildren: parent.children as PhrasingContent[],\n\t\t\tposition: parent.position,\n\t\t} satisfies Link,\n\t]\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\treadonly componentRoutes?: Record<string, string> | undefined\n}\n\nexport function fences(options: FencesOptions = {}) {\n\tconst componentRoutes = options.componentRoutes ?? {}\n\n\treturn function plugin(root: Root) {\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\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]\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...o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Q,CAAC;AAAA,IAC3C;AAAA,EACD;AACD;;;AXpDO,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","nodeToString","name","baseline","onlyParents","onlyParents","plugins","baseline"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@copepod/unified-plugins",
3
3
  "type": "module",
4
- "version": "0.5.0",
4
+ "version": "0.7.0",
5
5
  "description": "A collection of plugins",
6
6
  "author": "Julien Cayzac",
7
7
  "license": "MIT",