Explorar el Código

optional heading params

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

+ 2 - 2
index.mjs

@@ -621,10 +621,10 @@ function buildAST(md, mdTags=syntax, offset=0, tree={tag: 'root'}, stack=[]){
 const Heading = ({react:React, children, title, node: {tag, startMatch}}) => {
     const level = +tag.slice(-1)
     const _ = React.createElement.bind(React)
-    console.log(startMatch)
+    const [m, m1,m2, id, rest] = startMatch
     if (isNaN(level)) throw new SyntaxError('wrong heading name')
     return _(React.Fragment, null, 
-                _(`h${level}`, null, ...title),
+                _(`h${level}`, id && {id}, ...title),
                 _(`div`, null, ...children)
             )
 }