src/commonmark-react-renderer.js
function getNodeProps(node, key, opts, renderer) {
    var props = { key: key }, undef;

    // `sourcePos` is true if the user wants source information (line/column info from markdown source)
    if (opts.sourcePos && node.sourcepos) {
        props['data-sourcepos'] = flattenPosition(node.sourcepos);
    }

    var type = normalizeTypeName(node.type);

    switch (type) {
        case 'html_inline':
        case 'html_block':
            props.isBlock = type === 'html_block';
            props.escapeHtml = opts.escapeHtml;
            props.skipHtml = opts.skipHtml;
            break;
        case 'code_block':
            var codeInfo = node.info ? node.info.split(/ +/) : [];
            if (codeInfo.length > 0 && codeInfo[0].length > 0) {
                props.language = codeInfo[0];
                props.codeinfo = codeInfo;
            }
            break;
        case 'code':
            props.children = node.literal;
            props.inline = true;
            break;
        case 'heading':
            props.level = node.level;
            break;
        case 'softbreak':
            props.softBreak = opts.softBreak;
            break;
        case 'link':
            props.href = opts.transformLinkUri ? opts.transformLinkUri(node.destination) : node.destination;
            props.title = node.title || undef;
            if (opts.linkTarget) {
                props.target = opts.linkTarget;
            }
            break;
        case 'image':
            props.src = opts.transformImageUri ? opts.transformImageUri(node.destination) : node.destination;
            props.title = node.title || undef;

            // Commonmark treats image description as children. We just want the text
            props.alt = node.react.children.join('');
            node.react.children = undef;
            break;
        case 'list':
            props.start = node.listStart;
            props.type = node.listType;
            props.tight = node.listTight;
            break;
        default:
    }

    if (typeof renderer !== 'string') {
        props.literal = node.literal;
    }

    var children = props.children || (node.react && node.react.children);
    if (Array.isArray(children)) {
        props.children = children.reduce(reduceChildren, []) || null;
    }

    return props;
}
function getNodeProps(node, key, opts, renderer) {
    var props = { key: key }, undef;

    // `sourcePos` is true if the user wants source information (line/column info from markdown source)
    if (opts.sourcePos && node.sourcepos) {
        props['data-sourcepos'] = flattenPosition(node.sourcepos);
    }

    var type = normalizeTypeName(node.type);

    switch (type) {
        case 'html_inline':
        case 'html_block':
            props.isBlock = type === 'html_block';
            props.escapeHtml = opts.escapeHtml;
            props.skipHtml = opts.skipHtml;
            break;
        case 'code_block':
            var codeInfo = node.info ? node.info.split(/ +/) : [];
            if (codeInfo.length > 0 && codeInfo[0].length > 0) {
                props.language = codeInfo[0];
                props.codeinfo = codeInfo;
            }
            break;
        case 'code':
            props.children = node.literal;
            props.inline = true;
            break;
        case 'heading':
            props.level = node.level;
            break;
        case 'softbreak':
            props.softBreak = opts.softBreak;
            break;
        case 'link':
            props.href = opts.transformLinkUri ? opts.transformLinkUri(node.destination) : node.destination;
            props.title = node.title || undef;
            if (opts.linkTarget) {
                props.target = opts.linkTarget;
            }
            break;
        case 'image':
            props.src = opts.transformImageUri ? opts.transformImageUri(node.destination) : node.destination;
            props.title = node.title || undef;

            // Commonmark treats image description as children. We just want the text
            props.alt = node.react.children.join('');
            node.react.children = undef;
            break;
        case 'list':
            props.start = node.listStart;
            props.type = node.listType;
            props.tight = node.listTight;
            break;
        default:
    }

    if (typeof renderer !== 'string') {
        props.literal = node.literal;
    }

    var children = props.children || (node.react && node.react.children);
    if (Array.isArray(children)) {
        props.children = children.reduce(reduceChildren, []) || null;
    }

    return props;
}
function getNodeProps ( node , key , opts , renderer ) { var props = { key : key } , undef ; // `sourcePos` is true if the user wants source information (line/column info from markdown source) if ( opts . sourcePos && node . sourcepos ) { props [ 'data-sourcepos' ] = flattenPosition ( node . sourcepos ) ; } var type = normalizeTypeName ( node . type ) ; switch ( type ) { case 'html_inline' : case 'html_block' : props . isBlock = type === 'html_block' ; props . escapeHtml = opts . escapeHtml ; props . skipHtml = opts . skipHtml ; break ; case 'code_block' : var codeInfo = node . info ? node . info . split ( /  + / ) : [ ] ; if ( codeInfo . length > 0 && codeInfo [ 0 ] . length > 0 ) { props . language = codeInfo [ 0 ] ; props . codeinfo = codeInfo ; } break ; case 'code' : props . children = node . literal ; props . inline = true ; break ; case 'heading' : props . level = node . level ; break ; case 'softbreak' : props . softBreak = opts . softBreak ; break ; case 'link' : props . href = opts . transformLinkUri ? opts . transformLinkUri ( node . destination ) : node . destination ; props . title = node . title || undef ; if ( opts . linkTarget ) { props . target = opts . linkTarget ; } break ; case 'image' : props . src = opts . transformImageUri ? opts . transformImageUri ( node . destination ) : node . destination ; props . title = node . title || undef ; // Commonmark treats image description as children. We just want the text props . alt = node . react . children . join ( '' ) ; node . react . children = undef ; break ; case 'list' : props . start = node . listStart ; props . type = node . listType ; props . tight = node . listTight ; break ; default : } if ( typeof renderer !== 'string' ) { props . literal = node . literal ; } var children = props . children || ( node . react && node . react . children ) ; if ( Array . isArray ( children ) ) { props . children = children . reduce ( reduceChildren , [ ] ) || null ; } return props ; }
For some nodes, we want to include more props than for others
For some nodes we want to include more props than for others