UNPKG

remark-github-markdown-alerts

Version:

An unifiedjs (remark) plugin to convert GitHub Markdown alerts syntax into actual UI

41 lines (38 loc) 2.71 kB
import { Root, Blockquote } from 'mdast'; import { PartialDeep } from 'type-fest'; import { Plugin } from 'unified'; type HtmlElement = 'html' | 'head' | 'body' | 'base' | 'link' | 'meta' | 'style' | 'title' | 'address' | 'article' | 'aside' | 'footer' | 'header' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'hgroup' | 'main' | 'nav' | 'section' | 'search' | 'blockquote' | 'dd' | 'div' | 'dl' | 'dt' | 'figcaption' | 'figure' | 'hr' | 'li' | 'menu' | 'ol' | 'p' | 'pre' | 'ul' | 'a' | 'abbr' | 'b' | 'bdi' | 'bdo' | 'br' | 'cite' | 'code' | 'data' | 'dfn' | 'em' | 'i' | 'kbd' | 'mark' | 'q' | 'rp' | 'rt' | 'ruby' | 's' | 'samp' | 'small' | 'span' | 'strong' | 'sub' | 'sup' | 'time' | 'u' | 'var' | 'wbr' | 'area' | 'audio' | 'img' | 'map' | 'track' | 'video' | 'embed' | 'iframe' | 'object' | 'picture' | 'source' | 'svg' | 'math' | 'canvas' | 'noscript' | 'script' | 'del' | 'ins' | 'caption' | 'col' | 'colgroup' | 'table' | 'tbody' | 'td' | 'tfoot' | 'th' | 'thead' | 'tr' | 'button' | 'datalist' | 'fieldset' | 'form' | 'input' | 'label' | 'legend' | 'meter' | 'optgroup' | 'option' | 'output' | 'progress' | 'select' | 'textarea' | 'details' | 'dialog' | 'summary' | 'slot' | 'template'; type AlertConfig = { iconElementHtml: string; tags: { container: HtmlElement; icon: HtmlElement; title: HtmlElement; content: HtmlElement; }; classNames: { container: string; icon: string; title: string; content: string; }; }; type AlertsConfig = { note?: PartialDeep<AlertConfig>; tip?: PartialDeep<AlertConfig>; important?: PartialDeep<AlertConfig>; warning?: PartialDeep<AlertConfig>; caution?: PartialDeep<AlertConfig>; }; type RenderMode = 'html' | 'component' | 'auto'; type RemarkGitHubAlertsOptions = { alerts?: AlertsConfig; defaultConfig?: PartialDeep<AlertConfig>; mode?: RenderMode; }; declare function processBlockquoteAsComponent(node: Blockquote, index: number | undefined, parent: unknown, baseConfig: AlertConfig, alerts: AlertsConfig): boolean; declare function processBlockquoteAsHtml(node: Blockquote, index: number | undefined, parent: unknown, baseConfig: AlertConfig, alerts: AlertsConfig): boolean; declare function processBlockquote(node: Blockquote, index: number | undefined, parent: unknown, baseConfig: AlertConfig, alerts: AlertsConfig, mode?: RenderMode): boolean; declare const remarkGitHubAlerts: Plugin<[RemarkGitHubAlertsOptions?], Root>; export { remarkGitHubAlerts as default, processBlockquote, processBlockquoteAsComponent, processBlockquoteAsHtml, remarkGitHubAlerts }; export type { AlertConfig, AlertsConfig, RemarkGitHubAlertsOptions, RenderMode };