markdown-to-jsx 9.3.4 → 9.4.0

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/native.d.cts CHANGED
@@ -177,6 +177,7 @@ type RequireAtLeastOne<
177
177
  attrs?: Record<string, any>;
178
178
  children?: ASTNode[] | undefined;
179
179
  noInnerParse?: Boolean;
180
+ rawAttrs?: string;
180
181
  tag: string;
181
182
  text?: string | undefined;
182
183
  }
@@ -228,6 +229,31 @@ type RequireAtLeastOne<
228
229
  */
229
230
  enforceAtxHeadings: boolean;
230
231
  /**
232
+ * **⚠️ SECURITY WARNING: STRONGLY DISCOURAGED FOR USER INPUTS**
233
+ *
234
+ * When enabled, attempts to eval expressions in JSX props that cannot be serialized
235
+ * as JSON (functions, variables, complex expressions). This uses `eval()` which can
236
+ * execute arbitrary code.
237
+ *
238
+ * **ONLY use this option when:**
239
+ * - The markdown source is completely trusted (e.g., your own documentation)
240
+ * - You control all JSX components and their props
241
+ * - The content is NOT user-generated or user-editable
242
+ *
243
+ * **DO NOT use this option when:**
244
+ * - Processing user-submitted markdown
245
+ * - Rendering untrusted content
246
+ * - Building public-facing applications with user content
247
+ *
248
+ * Example unsafe input: `<Component onClick={() => fetch('/admin/delete-all')} />`
249
+ *
250
+ * When disabled (default), unserializable expressions remain as strings that can be
251
+ * safely inspected or handled on a case-by-case basis via custom renderRule logic.
252
+ *
253
+ * @default false
254
+ */
255
+ evalUnserializableExpressions?: boolean;
256
+ /**
231
257
  * Forces the compiler to always output content with a block-level wrapper
232
258
  * (`<p>` or any block-level syntax your markdown already contains.)
233
259
  */
@@ -336,6 +362,7 @@ declare global {
336
362
  declare function parser(source: string, options?: MarkdownToJSX.Options): MarkdownToJSX.ASTNode[];
337
363
  declare function sanitizer(input: string): string | null;
338
364
  declare function slugify(str: string): string;
365
+ declare const MarkdownContext: React2.Context<NativeOptions | undefined>;
339
366
  type NativeStyleKey = "text" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "link" | "image" | "codeBlock" | "codeInline" | "blockquote" | "listOrdered" | "listUnordered" | "listItem" | "listItemBullet" | "listItemNumber" | "thematicBreak" | "table" | "tableHeader" | "tableHeaderCell" | "tableRow" | "tableCell" | "em" | "strong" | "del" | "gfmTask" | "div" | "section" | "article" | "aside" | "header" | "footer" | "main" | "nav" | "figure" | "figcaption" | "ul" | "ol" | "li" | "th" | "td";
340
367
  type NativeOptions = Omit<MarkdownToJSX.Options, "wrapperProps"> & {
341
368
  onLinkPress?: (url: string, title?: string) => void;
@@ -345,8 +372,12 @@ type NativeOptions = Omit<MarkdownToJSX.Options, "wrapperProps"> & {
345
372
  };
346
373
  declare function astToNative(ast: MarkdownToJSX.ASTNode[], options?: NativeOptions): React2.ReactNode;
347
374
  declare function compiler(markdown?: string, options?: NativeOptions): React2.ReactNode;
375
+ declare const MarkdownProvider: React2.FC<{
376
+ options?: NativeOptions;
377
+ children: React2.ReactNode;
378
+ }>;
348
379
  declare const Markdown: React2.FC<Omit<ViewProps, "children"> & {
349
380
  children?: string | null;
350
381
  options?: NativeOptions;
351
382
  }>;
352
- export { slugify, sanitizer, parser, Markdown as default, compiler, astToNative, RuleType2 as RuleType, NativeStyleKey, NativeOptions, MarkdownToJSX, Markdown };
383
+ export { slugify, sanitizer, parser, Markdown as default, compiler, astToNative, RuleType2 as RuleType, NativeStyleKey, NativeOptions, MarkdownToJSX, MarkdownProvider, MarkdownContext, Markdown };
package/dist/native.d.ts CHANGED
@@ -177,6 +177,7 @@ type RequireAtLeastOne<
177
177
  attrs?: Record<string, any>;
178
178
  children?: ASTNode[] | undefined;
179
179
  noInnerParse?: Boolean;
180
+ rawAttrs?: string;
180
181
  tag: string;
181
182
  text?: string | undefined;
182
183
  }
@@ -228,6 +229,31 @@ type RequireAtLeastOne<
228
229
  */
229
230
  enforceAtxHeadings: boolean;
230
231
  /**
232
+ * **⚠️ SECURITY WARNING: STRONGLY DISCOURAGED FOR USER INPUTS**
233
+ *
234
+ * When enabled, attempts to eval expressions in JSX props that cannot be serialized
235
+ * as JSON (functions, variables, complex expressions). This uses `eval()` which can
236
+ * execute arbitrary code.
237
+ *
238
+ * **ONLY use this option when:**
239
+ * - The markdown source is completely trusted (e.g., your own documentation)
240
+ * - You control all JSX components and their props
241
+ * - The content is NOT user-generated or user-editable
242
+ *
243
+ * **DO NOT use this option when:**
244
+ * - Processing user-submitted markdown
245
+ * - Rendering untrusted content
246
+ * - Building public-facing applications with user content
247
+ *
248
+ * Example unsafe input: `<Component onClick={() => fetch('/admin/delete-all')} />`
249
+ *
250
+ * When disabled (default), unserializable expressions remain as strings that can be
251
+ * safely inspected or handled on a case-by-case basis via custom renderRule logic.
252
+ *
253
+ * @default false
254
+ */
255
+ evalUnserializableExpressions?: boolean;
256
+ /**
231
257
  * Forces the compiler to always output content with a block-level wrapper
232
258
  * (`<p>` or any block-level syntax your markdown already contains.)
233
259
  */
@@ -336,6 +362,7 @@ declare global {
336
362
  declare function parser(source: string, options?: MarkdownToJSX.Options): MarkdownToJSX.ASTNode[];
337
363
  declare function sanitizer(input: string): string | null;
338
364
  declare function slugify(str: string): string;
365
+ declare const MarkdownContext: React2.Context<NativeOptions | undefined>;
339
366
  type NativeStyleKey = "text" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "link" | "image" | "codeBlock" | "codeInline" | "blockquote" | "listOrdered" | "listUnordered" | "listItem" | "listItemBullet" | "listItemNumber" | "thematicBreak" | "table" | "tableHeader" | "tableHeaderCell" | "tableRow" | "tableCell" | "em" | "strong" | "del" | "gfmTask" | "div" | "section" | "article" | "aside" | "header" | "footer" | "main" | "nav" | "figure" | "figcaption" | "ul" | "ol" | "li" | "th" | "td";
340
367
  type NativeOptions = Omit<MarkdownToJSX.Options, "wrapperProps"> & {
341
368
  onLinkPress?: (url: string, title?: string) => void;
@@ -345,8 +372,12 @@ type NativeOptions = Omit<MarkdownToJSX.Options, "wrapperProps"> & {
345
372
  };
346
373
  declare function astToNative(ast: MarkdownToJSX.ASTNode[], options?: NativeOptions): React2.ReactNode;
347
374
  declare function compiler(markdown?: string, options?: NativeOptions): React2.ReactNode;
375
+ declare const MarkdownProvider: React2.FC<{
376
+ options?: NativeOptions;
377
+ children: React2.ReactNode;
378
+ }>;
348
379
  declare const Markdown: React2.FC<Omit<ViewProps, "children"> & {
349
380
  children?: string | null;
350
381
  options?: NativeOptions;
351
382
  }>;
352
- export { slugify, sanitizer, parser, Markdown as default, compiler, astToNative, RuleType2 as RuleType, NativeStyleKey, NativeOptions, MarkdownToJSX, Markdown };
383
+ export { slugify, sanitizer, parser, Markdown as default, compiler, astToNative, RuleType2 as RuleType, NativeStyleKey, NativeOptions, MarkdownToJSX, MarkdownProvider, MarkdownContext, Markdown };