Changes
2 changed files (+49/-26)
-
-
@@ -20,7 +20,6 @@ {type: "ofmCallout", calloutType: "info", isFoldable: false, title: [], children: [ { type: "paragraph",
-
@@ -59,7 +58,6 @@ type: "ofmCallout",calloutType: "danger", isFoldable: true, defaultExpanded: false, title: [], children: [ { type: "paragraph",
-
@@ -89,7 +87,6 @@ type: "ofmCallout",calloutType: "oops", isFoldable: true, defaultExpanded: true, title: [], children: [ { type: "paragraph",
-
@@ -119,19 +116,22 @@ type: "ofmCallout",calloutType: "todo", isFoldable: true, defaultExpanded: false, title: [ children: [ { type: "link", url: "https://example.com", type: "ofmCalloutTitle", children: [ { type: "text", value: "Foo", type: "link", url: "https://example.com", children: [ { type: "text", value: "Foo", }, ], }, ], }, ], children: [ { type: "paragraph", children: [
-
-
-
@@ -17,9 +17,13 @@ isFoldable: boolean;defaultExpanded?: boolean; title: Mdast.PhrasingContent[]; children: (OfmCalloutTitle | Mdast.BlockContent | Mdast.DefinitionContent)[]; } children: (Mdast.BlockContent | Mdast.DefinitionContent)[]; export interface OfmCalloutTitle extends Mdast.Node { type: "ofmCalloutTitle"; children: Mdast.PhrasingContent[]; } const PATTERN_REGEXP = /\[!(\S+)]([-+]?)(\s(.*))?$/;
-
@@ -126,6 +130,16 @@ }const [, type, expandSymbol, , titleTextRest] = match; const titleChildren: Mdast.PhrasingContent[] = [ titleTextRest ? { type: "text", value: (titleTextRest || ""), } satisfies Mdast.Text : null, ...titleRest, ].filter((t): t is NonNullable<typeof t> => !!t); return { type: "ofmCallout", calloutType: type || "",
-
@@ -133,16 +147,13 @@ isFoldable: !!expandSymbol,defaultExpanded: typeof expandSymbol === "string" ? expandSymbol === "+" : undefined, title: [ titleTextRest ? { type: "text", value: (titleTextRest || ""), } satisfies Mdast.Text : null, ...titleRest, ].filter((t): t is NonNullable<typeof t> => !!t), children: [ ...(titleChildren.length > 0 ? [{ type: "ofmCalloutTitle", children: titleChildren, }] as const : []), ...(splitted[1] ? [splitted[1]] : []), ...rest, ],
-
@@ -263,10 +274,20 @@ const titleId = generateTitleId(counter++);const icon = generateIcon?.(type); const title: Hast.ElementContent[] = node.title.length > 0 let mdastTitle: OfmCalloutTitle | null = null; const mdastBody: (Mdast.BlockContent | Mdast.DefinitionContent)[] = []; for (const child of node.children) { if (child.type === "ofmCalloutTitle") { mdastTitle = child; } else { mdastBody.push(child); } } const title: Hast.ElementContent[] = mdastTitle ? state.all({ type: "paragraph", children: node.title, children: mdastTitle.children, }) : [{ type: "text",
-
@@ -304,9 +325,11 @@ {type: "element", tagName: "div", properties: {}, // @ts-expect-error: unist-related libraries heavily relies on ambient module declarations, // which Deno does not support. APIs also don't accept type parameters. children: state.all(node), children: state.all( // @ts-expect-error: unist-related libraries heavily relies on ambient module declarations, // which Deno does not support. APIs also don't accept type parameters. { ...node, children: mdastBody } as OfmCallout, ), }, ], },
-