UNPKG

@md2docx/react-markdown

Version:

A modern, SSR-friendly React Markdown renderer that preserves the MDAST tree for reuse (e.g., mdast2docx), supports full JSX children, unified plugins, and component overrides.

2 lines (1 loc) 763 B
import{b as p,c}from"./chunk-YLKYTARQ.mjs";import{isValidElement as P,Fragment as m}from"react";import{jsx as n}from"react/jsx-runtime";var i=({children:r,markdownProps:o})=>{if(typeof r=="string")return n(c,{...o,children:r});if(Array.isArray(r)){let e=p();return r.map((s,t)=>n(i,{markdownProps:o,children:s},e+t))}if(P(r)){let e=r.type,s=r.props;return n(e,{...s,children:n(i,{markdownProps:o,children:s.children})})}return r},g=({children:r,wrapper:o,remarkPlugins:e,rehypePlugins:s,remarkRehypeOptions:t,astRef:d,components:k,skipHtml:u,...a})=>{let M=o!=null?o:Object.keys(a).length?"div":m;return n(M,{...a,children:n(i,{markdownProps:{remarkPlugins:e,rehypePlugins:s,remarkRehypeOptions:t,astRef:d,components:k,skipHtml:u},children:r})})};export{g as a};