markdown-to-jsx 9.0.0 → 9.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/html.d.cts CHANGED
@@ -40,9 +40,9 @@ type RequireAtLeastOne<
40
40
  T,
41
41
  Keys extends keyof T = keyof T
42
42
  > = Pick<T, Exclude<keyof T, Keys>> & { [K in Keys]-? : Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>> }[Keys];
43
- type CreateElement = typeof React.createElement;
44
- type HTMLTags = keyof React.JSX.IntrinsicElements & (string & {});
45
- type State = {
43
+ export type CreateElement = typeof React.createElement;
44
+ export type HTMLTags = keyof React.JSX.IntrinsicElements & (string & {});
45
+ export type State = {
46
46
  /** true if the current content is inside anchor link grammar */
47
47
  inAnchor?: boolean;
48
48
  /** true if inside a blockquote */
@@ -65,82 +65,82 @@ type RequireAtLeastOne<
65
65
  /** current recursion depth during rendering */
66
66
  renderDepth?: number;
67
67
  };
68
- interface BlockQuoteNode {
68
+ export interface BlockQuoteNode {
69
69
  alert?: string;
70
70
  children: MarkdownToJSX.ASTNode[];
71
71
  type: typeof RuleType2.blockQuote;
72
72
  }
73
- interface BreakLineNode {
73
+ export interface BreakLineNode {
74
74
  type: typeof RuleType2.breakLine;
75
75
  }
76
- interface BreakThematicNode {
76
+ export interface BreakThematicNode {
77
77
  type: typeof RuleType2.breakThematic;
78
78
  }
79
- interface CodeBlockNode {
79
+ export interface CodeBlockNode {
80
80
  type: typeof RuleType2.codeBlock;
81
81
  attrs?: React.JSX.IntrinsicAttributes;
82
82
  lang?: string;
83
83
  text: string;
84
84
  }
85
- interface CodeInlineNode {
85
+ export interface CodeInlineNode {
86
86
  type: typeof RuleType2.codeInline;
87
87
  text: string;
88
88
  }
89
- interface FootnoteNode {
89
+ export interface FootnoteNode {
90
90
  type: typeof RuleType2.footnote;
91
91
  }
92
- interface FootnoteReferenceNode {
92
+ export interface FootnoteReferenceNode {
93
93
  type: typeof RuleType2.footnoteReference;
94
94
  target: string;
95
95
  text: string;
96
96
  }
97
- interface FrontmatterNode {
97
+ export interface FrontmatterNode {
98
98
  type: typeof RuleType2.frontmatter;
99
99
  text: string;
100
100
  }
101
- interface GFMTaskNode {
101
+ export interface GFMTaskNode {
102
102
  type: typeof RuleType2.gfmTask;
103
103
  completed: boolean;
104
104
  }
105
- interface HeadingNode {
105
+ export interface HeadingNode {
106
106
  type: typeof RuleType2.heading;
107
107
  children: MarkdownToJSX.ASTNode[];
108
108
  id: string;
109
109
  level: 1 | 2 | 3 | 4 | 5 | 6;
110
110
  }
111
- interface HTMLCommentNode {
111
+ export interface HTMLCommentNode {
112
112
  type: typeof RuleType2.htmlComment;
113
113
  text: string;
114
114
  }
115
- interface ImageNode {
115
+ export interface ImageNode {
116
116
  type: typeof RuleType2.image;
117
117
  alt?: string;
118
118
  target: string;
119
119
  title?: string;
120
120
  }
121
- interface LinkNode {
121
+ export interface LinkNode {
122
122
  type: typeof RuleType2.link;
123
123
  children: MarkdownToJSX.ASTNode[];
124
124
  target: string | null;
125
125
  title?: string;
126
126
  }
127
- interface OrderedListNode {
127
+ export interface OrderedListNode {
128
128
  type: typeof RuleType2.orderedList;
129
129
  items: MarkdownToJSX.ASTNode[][];
130
130
  start?: number;
131
131
  }
132
- interface UnorderedListNode {
132
+ export interface UnorderedListNode {
133
133
  type: typeof RuleType2.unorderedList;
134
134
  items: MarkdownToJSX.ASTNode[][];
135
135
  }
136
- interface ParagraphNode {
136
+ export interface ParagraphNode {
137
137
  type: typeof RuleType2.paragraph;
138
138
  children: MarkdownToJSX.ASTNode[];
139
139
  }
140
- interface ReferenceNode {
140
+ export interface ReferenceNode {
141
141
  type: typeof RuleType2.ref;
142
142
  }
143
- interface ReferenceCollectionNode {
143
+ export interface ReferenceCollectionNode {
144
144
  type: typeof RuleType2.refCollection;
145
145
  refs: {
146
146
  [key: string]: {
@@ -149,7 +149,7 @@ type RequireAtLeastOne<
149
149
  };
150
150
  };
151
151
  }
152
- interface TableNode {
152
+ export interface TableNode {
153
153
  type: typeof RuleType2.table;
154
154
  /**
155
155
  * alignment for each table column
@@ -158,11 +158,11 @@ type RequireAtLeastOne<
158
158
  cells: MarkdownToJSX.ASTNode[][][];
159
159
  header: MarkdownToJSX.ASTNode[][];
160
160
  }
161
- interface TextNode {
161
+ export interface TextNode {
162
162
  type: typeof RuleType2.text;
163
163
  text: string;
164
164
  }
165
- interface FormattedTextNode {
165
+ export interface FormattedTextNode {
166
166
  type: typeof RuleType2.textFormatted;
167
167
  /**
168
168
  * the corresponding html tag
@@ -170,7 +170,7 @@ type RequireAtLeastOne<
170
170
  tag: string;
171
171
  children: MarkdownToJSX.ASTNode[];
172
172
  }
173
- interface HTMLNode {
173
+ export interface HTMLNode {
174
174
  type: typeof RuleType2.htmlBlock;
175
175
  attrs?: Record<string, any>;
176
176
  children?: ASTNode[] | undefined;
@@ -178,22 +178,22 @@ type RequireAtLeastOne<
178
178
  tag: string;
179
179
  text?: string | undefined;
180
180
  }
181
- interface HTMLSelfClosingNode {
181
+ export interface HTMLSelfClosingNode {
182
182
  type: typeof RuleType2.htmlSelfClosing;
183
183
  attrs?: Record<string, any>;
184
184
  isClosingTag?: boolean;
185
185
  tag: string;
186
186
  }
187
- type ASTNode = BlockQuoteNode | BreakLineNode | BreakThematicNode | CodeBlockNode | CodeInlineNode | FootnoteNode | FootnoteReferenceNode | FrontmatterNode | GFMTaskNode | HeadingNode | HTMLCommentNode | ImageNode | LinkNode | OrderedListNode | UnorderedListNode | ParagraphNode | ReferenceNode | ReferenceCollectionNode | TableNode | TextNode | FormattedTextNode | HTMLNode | HTMLSelfClosingNode;
188
- type ASTRender = (ast: MarkdownToJSX.ASTNode | MarkdownToJSX.ASTNode[], state: MarkdownToJSX.State) => React.ReactNode;
189
- type Override = RequireAtLeastOne<{
187
+ export type ASTNode = BlockQuoteNode | BreakLineNode | BreakThematicNode | CodeBlockNode | CodeInlineNode | FootnoteNode | FootnoteReferenceNode | FrontmatterNode | GFMTaskNode | HeadingNode | HTMLCommentNode | ImageNode | LinkNode | OrderedListNode | UnorderedListNode | ParagraphNode | ReferenceNode | ReferenceCollectionNode | TableNode | TextNode | FormattedTextNode | HTMLNode | HTMLSelfClosingNode;
188
+ export type ASTRender = (ast: MarkdownToJSX.ASTNode | MarkdownToJSX.ASTNode[], state: MarkdownToJSX.State) => React.ReactNode;
189
+ export type Override = RequireAtLeastOne<{
190
190
  component: React.ElementType;
191
191
  props: Object;
192
192
  }> | React.ElementType;
193
- type Overrides = { [tag in HTMLTags]? : Override } & {
193
+ export type Overrides = { [tag in HTMLTags]? : Override } & {
194
194
  [customComponent: string]: Override;
195
195
  };
196
- type Options = Partial<{
196
+ export type Options = Partial<{
197
197
  /**
198
198
  * Ultimate control over the output of all rendered JSX.
199
199
  */
@@ -268,7 +268,7 @@ type RequireAtLeastOne<
268
268
  renderRule: (next: () => React.ReactNode, node: ASTNode, renderChildren: ASTRender, state: State) => React.ReactNode;
269
269
  /**
270
270
  * Override the built-in sanitizer function for URLs, etc if desired. The built-in version is available as a library
271
- called `sanitizer`.
271
+ export called `sanitizer`.
272
272
  */
273
273
  sanitizer: (value: string, tag: HTMLTags, attribute: string) => string | null;
274
274
  /**
@@ -287,9 +287,13 @@ type RequireAtLeastOne<
287
287
  * Props to apply to the wrapper element.
288
288
  */
289
289
  wrapperProps?: React.JSX.IntrinsicAttributes;
290
+ /**
291
+ * Preserve frontmatter in the output by rendering it as a <pre> element.
292
+ * By default, frontmatter is parsed but not rendered.
293
+ * @default false
294
+ */
295
+ preserveFrontmatter?: boolean;
290
296
  }>;
291
- {}
292
- ;
293
297
  }
294
298
  declare const RuleType2: typeof RuleTypeConst;
295
299
  type RuleType2 = RuleTypeValue;
package/dist/html.d.ts CHANGED
@@ -40,9 +40,9 @@ type RequireAtLeastOne<
40
40
  T,
41
41
  Keys extends keyof T = keyof T
42
42
  > = Pick<T, Exclude<keyof T, Keys>> & { [K in Keys]-? : Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>> }[Keys];
43
- type CreateElement = typeof React.createElement;
44
- type HTMLTags = keyof React.JSX.IntrinsicElements & (string & {});
45
- type State = {
43
+ export type CreateElement = typeof React.createElement;
44
+ export type HTMLTags = keyof React.JSX.IntrinsicElements & (string & {});
45
+ export type State = {
46
46
  /** true if the current content is inside anchor link grammar */
47
47
  inAnchor?: boolean;
48
48
  /** true if inside a blockquote */
@@ -65,82 +65,82 @@ type RequireAtLeastOne<
65
65
  /** current recursion depth during rendering */
66
66
  renderDepth?: number;
67
67
  };
68
- interface BlockQuoteNode {
68
+ export interface BlockQuoteNode {
69
69
  alert?: string;
70
70
  children: MarkdownToJSX.ASTNode[];
71
71
  type: typeof RuleType2.blockQuote;
72
72
  }
73
- interface BreakLineNode {
73
+ export interface BreakLineNode {
74
74
  type: typeof RuleType2.breakLine;
75
75
  }
76
- interface BreakThematicNode {
76
+ export interface BreakThematicNode {
77
77
  type: typeof RuleType2.breakThematic;
78
78
  }
79
- interface CodeBlockNode {
79
+ export interface CodeBlockNode {
80
80
  type: typeof RuleType2.codeBlock;
81
81
  attrs?: React.JSX.IntrinsicAttributes;
82
82
  lang?: string;
83
83
  text: string;
84
84
  }
85
- interface CodeInlineNode {
85
+ export interface CodeInlineNode {
86
86
  type: typeof RuleType2.codeInline;
87
87
  text: string;
88
88
  }
89
- interface FootnoteNode {
89
+ export interface FootnoteNode {
90
90
  type: typeof RuleType2.footnote;
91
91
  }
92
- interface FootnoteReferenceNode {
92
+ export interface FootnoteReferenceNode {
93
93
  type: typeof RuleType2.footnoteReference;
94
94
  target: string;
95
95
  text: string;
96
96
  }
97
- interface FrontmatterNode {
97
+ export interface FrontmatterNode {
98
98
  type: typeof RuleType2.frontmatter;
99
99
  text: string;
100
100
  }
101
- interface GFMTaskNode {
101
+ export interface GFMTaskNode {
102
102
  type: typeof RuleType2.gfmTask;
103
103
  completed: boolean;
104
104
  }
105
- interface HeadingNode {
105
+ export interface HeadingNode {
106
106
  type: typeof RuleType2.heading;
107
107
  children: MarkdownToJSX.ASTNode[];
108
108
  id: string;
109
109
  level: 1 | 2 | 3 | 4 | 5 | 6;
110
110
  }
111
- interface HTMLCommentNode {
111
+ export interface HTMLCommentNode {
112
112
  type: typeof RuleType2.htmlComment;
113
113
  text: string;
114
114
  }
115
- interface ImageNode {
115
+ export interface ImageNode {
116
116
  type: typeof RuleType2.image;
117
117
  alt?: string;
118
118
  target: string;
119
119
  title?: string;
120
120
  }
121
- interface LinkNode {
121
+ export interface LinkNode {
122
122
  type: typeof RuleType2.link;
123
123
  children: MarkdownToJSX.ASTNode[];
124
124
  target: string | null;
125
125
  title?: string;
126
126
  }
127
- interface OrderedListNode {
127
+ export interface OrderedListNode {
128
128
  type: typeof RuleType2.orderedList;
129
129
  items: MarkdownToJSX.ASTNode[][];
130
130
  start?: number;
131
131
  }
132
- interface UnorderedListNode {
132
+ export interface UnorderedListNode {
133
133
  type: typeof RuleType2.unorderedList;
134
134
  items: MarkdownToJSX.ASTNode[][];
135
135
  }
136
- interface ParagraphNode {
136
+ export interface ParagraphNode {
137
137
  type: typeof RuleType2.paragraph;
138
138
  children: MarkdownToJSX.ASTNode[];
139
139
  }
140
- interface ReferenceNode {
140
+ export interface ReferenceNode {
141
141
  type: typeof RuleType2.ref;
142
142
  }
143
- interface ReferenceCollectionNode {
143
+ export interface ReferenceCollectionNode {
144
144
  type: typeof RuleType2.refCollection;
145
145
  refs: {
146
146
  [key: string]: {
@@ -149,7 +149,7 @@ type RequireAtLeastOne<
149
149
  };
150
150
  };
151
151
  }
152
- interface TableNode {
152
+ export interface TableNode {
153
153
  type: typeof RuleType2.table;
154
154
  /**
155
155
  * alignment for each table column
@@ -158,11 +158,11 @@ type RequireAtLeastOne<
158
158
  cells: MarkdownToJSX.ASTNode[][][];
159
159
  header: MarkdownToJSX.ASTNode[][];
160
160
  }
161
- interface TextNode {
161
+ export interface TextNode {
162
162
  type: typeof RuleType2.text;
163
163
  text: string;
164
164
  }
165
- interface FormattedTextNode {
165
+ export interface FormattedTextNode {
166
166
  type: typeof RuleType2.textFormatted;
167
167
  /**
168
168
  * the corresponding html tag
@@ -170,7 +170,7 @@ type RequireAtLeastOne<
170
170
  tag: string;
171
171
  children: MarkdownToJSX.ASTNode[];
172
172
  }
173
- interface HTMLNode {
173
+ export interface HTMLNode {
174
174
  type: typeof RuleType2.htmlBlock;
175
175
  attrs?: Record<string, any>;
176
176
  children?: ASTNode[] | undefined;
@@ -178,22 +178,22 @@ type RequireAtLeastOne<
178
178
  tag: string;
179
179
  text?: string | undefined;
180
180
  }
181
- interface HTMLSelfClosingNode {
181
+ export interface HTMLSelfClosingNode {
182
182
  type: typeof RuleType2.htmlSelfClosing;
183
183
  attrs?: Record<string, any>;
184
184
  isClosingTag?: boolean;
185
185
  tag: string;
186
186
  }
187
- type ASTNode = BlockQuoteNode | BreakLineNode | BreakThematicNode | CodeBlockNode | CodeInlineNode | FootnoteNode | FootnoteReferenceNode | FrontmatterNode | GFMTaskNode | HeadingNode | HTMLCommentNode | ImageNode | LinkNode | OrderedListNode | UnorderedListNode | ParagraphNode | ReferenceNode | ReferenceCollectionNode | TableNode | TextNode | FormattedTextNode | HTMLNode | HTMLSelfClosingNode;
188
- type ASTRender = (ast: MarkdownToJSX.ASTNode | MarkdownToJSX.ASTNode[], state: MarkdownToJSX.State) => React.ReactNode;
189
- type Override = RequireAtLeastOne<{
187
+ export type ASTNode = BlockQuoteNode | BreakLineNode | BreakThematicNode | CodeBlockNode | CodeInlineNode | FootnoteNode | FootnoteReferenceNode | FrontmatterNode | GFMTaskNode | HeadingNode | HTMLCommentNode | ImageNode | LinkNode | OrderedListNode | UnorderedListNode | ParagraphNode | ReferenceNode | ReferenceCollectionNode | TableNode | TextNode | FormattedTextNode | HTMLNode | HTMLSelfClosingNode;
188
+ export type ASTRender = (ast: MarkdownToJSX.ASTNode | MarkdownToJSX.ASTNode[], state: MarkdownToJSX.State) => React.ReactNode;
189
+ export type Override = RequireAtLeastOne<{
190
190
  component: React.ElementType;
191
191
  props: Object;
192
192
  }> | React.ElementType;
193
- type Overrides = { [tag in HTMLTags]? : Override } & {
193
+ export type Overrides = { [tag in HTMLTags]? : Override } & {
194
194
  [customComponent: string]: Override;
195
195
  };
196
- type Options = Partial<{
196
+ export type Options = Partial<{
197
197
  /**
198
198
  * Ultimate control over the output of all rendered JSX.
199
199
  */
@@ -268,7 +268,7 @@ type RequireAtLeastOne<
268
268
  renderRule: (next: () => React.ReactNode, node: ASTNode, renderChildren: ASTRender, state: State) => React.ReactNode;
269
269
  /**
270
270
  * Override the built-in sanitizer function for URLs, etc if desired. The built-in version is available as a library
271
- called `sanitizer`.
271
+ export called `sanitizer`.
272
272
  */
273
273
  sanitizer: (value: string, tag: HTMLTags, attribute: string) => string | null;
274
274
  /**
@@ -287,9 +287,13 @@ type RequireAtLeastOne<
287
287
  * Props to apply to the wrapper element.
288
288
  */
289
289
  wrapperProps?: React.JSX.IntrinsicAttributes;
290
+ /**
291
+ * Preserve frontmatter in the output by rendering it as a <pre> element.
292
+ * By default, frontmatter is parsed but not rendered.
293
+ * @default false
294
+ */
295
+ preserveFrontmatter?: boolean;
290
296
  }>;
291
- {}
292
- ;
293
297
  }
294
298
  declare const RuleType2: typeof RuleTypeConst;
295
299
  type RuleType2 = RuleTypeValue;