Explorar el Código

optional heading params

Ivan Asmer hace 4 años
padre
commit
0b4738e092
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. 3 2
      index.mjs

+ 3 - 2
index.mjs

@@ -618,9 +618,10 @@ function buildAST(md, mdTags=syntax, offset=0, tree={tag: 'root'}, stack=[]){
     return currentNode
 }
 
-const Heading = ({react:React, children, title, node: {tag}}) => {
+const Heading = ({react:React, children, title, node: {tag, startMatch}}) => {
     const level = +tag.slice(-1)
     const _ = React.createElement.bind(React)
+    console.log(startMatch)
     if (isNaN(level)) throw new SyntaxError('wrong heading name')
     return _(React.Fragment, null, 
                 _(`h${level}`, null, ...title),
@@ -638,7 +639,7 @@ const Img = ({react:React, children, title, node}) =>{
     return _("img", {alt: title, src: children, className: node.startMatch[1] || undefined})
 }
 
-const defaultMapMDToComponents = {
+export const defaultMapMDToComponents = {
     heading1: Heading,
     heading2: Heading,
     heading3: Heading,