UNPKG

3.33 kBTypeScriptView Raw
1/**
2 * Component to render markdown.
3 *
4 * @param {Readonly<Options>} options
5 * Props.
6 * @returns {JSX.Element}
7 * React element.
8 */
9export function Markdown(options: Readonly<Options>): JSX.Element;
10/**
11 * Make a URL safe.
12 *
13 * @satisfies {UrlTransform}
14 * @param {string} value
15 * URL.
16 * @returns {string}
17 * Safe URL.
18 */
19export function defaultUrlTransform(value: string): string;
20export type Element = import('hast').Element;
21export type ElementContent = import('hast').ElementContent;
22export type Nodes = import('hast').Nodes;
23export type Parents = import('hast').Parents;
24export type Root = import('hast').Root;
25export type JsxRuntimeComponents = import('hast-util-to-jsx-runtime').Components;
26export type RemarkRehypeOptions = import('remark-rehype').Options;
27export type Visitor = import('unist-util-visit').BuildVisitor<Root>;
28export type PluggableList = import('unified').PluggableList;
29/**
30 * Filter elements.
31 */
32export type AllowElement = (element: Readonly<Element>, index: number, parent: Readonly<Parents> | undefined) => boolean | null | undefined;
33/**
34 * Map tag names to components.
35 */
36export type Components = Partial<JsxRuntimeComponents>;
37/**
38 * Deprecation.
39 */
40export type Deprecation = {
41 /**
42 * Old field.
43 */
44 from: string;
45 /**
46 * ID in readme.
47 */
48 id: string;
49 /**
50 * New field.
51 */
52 to?: keyof Options;
53};
54/**
55 * Configuration.
56 */
57export type Options = {
58 /**
59 * Filter elements (optional);
60 * `allowedElements` / `disallowedElements` is used first.
61 */
62 allowElement?: AllowElement | null | undefined;
63 /**
64 * Tag names to allow (default: all tag names);
65 * cannot combine w/ `disallowedElements`.
66 */
67 allowedElements?: ReadonlyArray<string> | null | undefined;
68 /**
69 * Markdown.
70 */
71 children?: string | null | undefined;
72 /**
73 * Wrap in a `div` with this class name.
74 */
75 className?: string | null | undefined;
76 /**
77 * Map tag names to components.
78 */
79 components?: Components | null | undefined;
80 /**
81 * Tag names to disallow (default: `[]`);
82 * cannot combine w/ `allowedElements`.
83 */
84 disallowedElements?: ReadonlyArray<string> | null | undefined;
85 /**
86 * List of rehype plugins to use.
87 */
88 rehypePlugins?: import("unified").PluggableList | null | undefined;
89 /**
90 * List of remark plugins to use.
91 */
92 remarkPlugins?: import("unified").PluggableList | null | undefined;
93 /**
94 * Options to pass through to `remark-rehype`.
95 */
96 remarkRehypeOptions?: Readonly<RemarkRehypeOptions> | null | undefined;
97 /**
98 * Ignore HTML in markdown completely (default: `false`).
99 */
100 skipHtml?: boolean | null | undefined;
101 /**
102 * Extract (unwrap) what’s in disallowed elements (default: `false`);
103 * normally when say `strong` is not allowed, it and it’s children are dropped,
104 * with `unwrapDisallowed` the element itself is replaced by its children.
105 */
106 unwrapDisallowed?: boolean | null | undefined;
107 /**
108 * Change URLs (default: `defaultUrlTransform`)
109 */
110 urlTransform?: UrlTransform | null | undefined;
111};
112/**
113 * Transform all URLs.
114 */
115export type UrlTransform = (url: string, key: string, node: Readonly<Element>) => string | null | undefined;