@braindb/mdast-util-wiki-link
Version:
Parse and render wiki-style links
43 lines (42 loc) • 1.24 kB
TypeScript
import { type CompileContext, type Token } from "mdast-util-from-markdown";
import { type Node, type Data } from "unist";
interface WikiLinkHProperties {
className: string;
href: string;
[key: string]: unknown;
}
interface WikiLinkData extends Data {
alias: string;
permalink: string | undefined;
hName: string;
hProperties: WikiLinkHProperties;
hChildren: Array<{
type: string;
value: string;
}>;
}
export interface WikiLinkNode extends Node {
data: WikiLinkData;
value: string;
}
type LinkTemplateProps = {
slug: string;
permalink?: string;
alias?: string;
};
declare function defaultLinkTemplate({ slug, permalink, alias, }: LinkTemplateProps): any;
export interface FromMarkdownOptions {
linkResolver?: (x: string) => string;
linkTemplate?: typeof defaultLinkTemplate;
}
export declare function fromMarkdown(opts?: FromMarkdownOptions): {
enter: {
wikiLink: (this: CompileContext, token: Token) => void;
};
exit: {
wikiLinkTarget: (this: CompileContext, token: Token) => void;
wikiLinkAlias: (this: CompileContext, token: Token) => void;
wikiLink: (this: CompileContext, token: Token) => void;
};
};
export {};