markdown-to-jsx 9.3.5 → 9.4.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/react.d.cts CHANGED
@@ -175,9 +175,12 @@ type RequireAtLeastOne<
175
175
  type: typeof RuleType2.htmlBlock;
176
176
  attrs?: Record<string, any>;
177
177
  children?: ASTNode[] | undefined;
178
- noInnerParse?: Boolean;
179
- tag: string;
178
+ verbatim?: boolean;
179
+ rawAttrs?: string;
180
+ rawText?: string | undefined;
181
+ /** @deprecated Use `rawText` instead. This property will be removed in a future major version. */
180
182
  text?: string | undefined;
183
+ tag: string;
181
184
  }
182
185
  export interface HTMLSelfClosingNode {
183
186
  type: typeof RuleType2.htmlSelfClosing;
@@ -227,6 +230,31 @@ type RequireAtLeastOne<
227
230
  */
228
231
  enforceAtxHeadings: boolean;
229
232
  /**
233
+ * **⚠️ SECURITY WARNING: STRONGLY DISCOURAGED FOR USER INPUTS**
234
+ *
235
+ * When enabled, attempts to eval expressions in JSX props that cannot be serialized
236
+ * as JSON (functions, variables, complex expressions). This uses `eval()` which can
237
+ * execute arbitrary code.
238
+ *
239
+ * **ONLY use this option when:**
240
+ * - The markdown source is completely trusted (e.g., your own documentation)
241
+ * - You control all JSX components and their props
242
+ * - The content is NOT user-generated or user-editable
243
+ *
244
+ * **DO NOT use this option when:**
245
+ * - Processing user-submitted markdown
246
+ * - Rendering untrusted content
247
+ * - Building public-facing applications with user content
248
+ *
249
+ * Example unsafe input: `<Component onClick={() => fetch('/admin/delete-all')} />`
250
+ *
251
+ * When disabled (default), unserializable expressions remain as strings that can be
252
+ * safely inspected or handled on a case-by-case basis via custom renderRule logic.
253
+ *
254
+ * @default false
255
+ */
256
+ evalUnserializableExpressions?: boolean;
257
+ /**
230
258
  * Forces the compiler to always output content with a block-level wrapper
231
259
  * (`<p>` or any block-level syntax your markdown already contains.)
232
260
  */
@@ -335,14 +363,19 @@ declare global {
335
363
  declare function parser(source: string, options?: MarkdownToJSX.Options): MarkdownToJSX.ASTNode[];
336
364
  declare function sanitizer(input: string): string | null;
337
365
  declare function slugify(str: string): string;
366
+ declare const MarkdownContext: React2.Context<MarkdownToJSX.Options | undefined>;
338
367
  declare function astToJSX(ast: MarkdownToJSX.ASTNode[], options?: MarkdownToJSX.Options): React2.ReactNode;
339
368
  declare function compiler(markdown?: string, options?: MarkdownToJSX.Options): React2.ReactNode;
369
+ declare const MarkdownProvider: React2.FC<{
370
+ options?: MarkdownToJSX.Options;
371
+ children: React2.ReactNode;
372
+ }>;
340
373
  /**
341
- * A simple HOC for easy React use. Feed the markdown content as a direct child
342
- * and the rest is taken care of automatically.
374
+ * A React component for easy markdown rendering. Feed the markdown content as a direct child
375
+ * and the rest is taken care of automatically. Supports memoization for optimal performance.
343
376
  */
344
377
  declare const Markdown: React2.FC<Omit<React2.HTMLAttributes<Element>, "children"> & {
345
378
  children?: string | null;
346
379
  options?: MarkdownToJSX.Options;
347
380
  }>;
348
- export { slugify, sanitizer, parser, Markdown as default, compiler, astToJSX, RuleType2 as RuleType, MarkdownToJSX, Markdown };
381
+ export { slugify, sanitizer, parser, Markdown as default, compiler, astToJSX, RuleType2 as RuleType, MarkdownToJSX, MarkdownProvider, MarkdownContext, Markdown };
package/dist/react.d.ts CHANGED
@@ -175,9 +175,12 @@ type RequireAtLeastOne<
175
175
  type: typeof RuleType2.htmlBlock;
176
176
  attrs?: Record<string, any>;
177
177
  children?: ASTNode[] | undefined;
178
- noInnerParse?: Boolean;
179
- tag: string;
178
+ verbatim?: boolean;
179
+ rawAttrs?: string;
180
+ rawText?: string | undefined;
181
+ /** @deprecated Use `rawText` instead. This property will be removed in a future major version. */
180
182
  text?: string | undefined;
183
+ tag: string;
181
184
  }
182
185
  export interface HTMLSelfClosingNode {
183
186
  type: typeof RuleType2.htmlSelfClosing;
@@ -227,6 +230,31 @@ type RequireAtLeastOne<
227
230
  */
228
231
  enforceAtxHeadings: boolean;
229
232
  /**
233
+ * **⚠️ SECURITY WARNING: STRONGLY DISCOURAGED FOR USER INPUTS**
234
+ *
235
+ * When enabled, attempts to eval expressions in JSX props that cannot be serialized
236
+ * as JSON (functions, variables, complex expressions). This uses `eval()` which can
237
+ * execute arbitrary code.
238
+ *
239
+ * **ONLY use this option when:**
240
+ * - The markdown source is completely trusted (e.g., your own documentation)
241
+ * - You control all JSX components and their props
242
+ * - The content is NOT user-generated or user-editable
243
+ *
244
+ * **DO NOT use this option when:**
245
+ * - Processing user-submitted markdown
246
+ * - Rendering untrusted content
247
+ * - Building public-facing applications with user content
248
+ *
249
+ * Example unsafe input: `<Component onClick={() => fetch('/admin/delete-all')} />`
250
+ *
251
+ * When disabled (default), unserializable expressions remain as strings that can be
252
+ * safely inspected or handled on a case-by-case basis via custom renderRule logic.
253
+ *
254
+ * @default false
255
+ */
256
+ evalUnserializableExpressions?: boolean;
257
+ /**
230
258
  * Forces the compiler to always output content with a block-level wrapper
231
259
  * (`<p>` or any block-level syntax your markdown already contains.)
232
260
  */
@@ -335,14 +363,19 @@ declare global {
335
363
  declare function parser(source: string, options?: MarkdownToJSX.Options): MarkdownToJSX.ASTNode[];
336
364
  declare function sanitizer(input: string): string | null;
337
365
  declare function slugify(str: string): string;
366
+ declare const MarkdownContext: React2.Context<MarkdownToJSX.Options | undefined>;
338
367
  declare function astToJSX(ast: MarkdownToJSX.ASTNode[], options?: MarkdownToJSX.Options): React2.ReactNode;
339
368
  declare function compiler(markdown?: string, options?: MarkdownToJSX.Options): React2.ReactNode;
369
+ declare const MarkdownProvider: React2.FC<{
370
+ options?: MarkdownToJSX.Options;
371
+ children: React2.ReactNode;
372
+ }>;
340
373
  /**
341
- * A simple HOC for easy React use. Feed the markdown content as a direct child
342
- * and the rest is taken care of automatically.
374
+ * A React component for easy markdown rendering. Feed the markdown content as a direct child
375
+ * and the rest is taken care of automatically. Supports memoization for optimal performance.
343
376
  */
344
377
  declare const Markdown: React2.FC<Omit<React2.HTMLAttributes<Element>, "children"> & {
345
378
  children?: string | null;
346
379
  options?: MarkdownToJSX.Options;
347
380
  }>;
348
- export { slugify, sanitizer, parser, Markdown as default, compiler, astToJSX, RuleType2 as RuleType, MarkdownToJSX, Markdown };
381
+ export { slugify, sanitizer, parser, Markdown as default, compiler, astToJSX, RuleType2 as RuleType, MarkdownToJSX, MarkdownProvider, MarkdownContext, Markdown };