UNPKG

@fedify/markdown-it-mention

Version:

A markdown-it plugin that parses and renders Mastodon-style @mentions.

44 lines 1.79 kB
import type { PluginWithOptions } from "markdown-it"; /** * Options for the plugin. */ export interface PluginOptions { /** * A function to determine the domain of a bare handle. If it returns `null`, * the bare handle will be rendered as plain text. `null` by default. * @param bareHandle The bare handle, e.g., `"@john"`. * @param env The environment. * @returns The local domain of the handle or `null` if the handle should be * plain text. * @since 0.3.0 */ localDomain?: (bareHandle: string, env: any) => string | null; /** * A function to render a link href for a mention. If it returns `null`, * the mention will be rendered as plain text. `acct:${handle}` by default. * @param handle The handle, e.g., `"@john@example.com"`. * @param env The environment. * @returns The link href or `null` if the mention should be plain text. */ link?: (handle: string, env: any) => string | null; /** * A function to render extra attributes for a mention link. * @param handle The handle, e.g., `"@john@example.com"`. * @param env The environment. * @returns The extra attributes of the link (`<a>` tag). */ linkAttributes?: (handle: string, env: any) => Record<string, string>; /** * A function to render a label for a mention link. {@link toBareHandle} * by default. * @param handle The handle, e.g., `"@john@example.com"`. * @param env The environment. * @returns The label of the link in HTML. */ label?: (handle: string, env: any) => string; } /** * A markdown-it plugin to parse and render Mastodon-style mentions. */ export declare const mention: PluginWithOptions<PluginOptions>; //# sourceMappingURL=plugin.d.ts.map