MCPcopy
hub / github.com/evilstreak/markdown-js / add

Function add

lib/markdown.js:449–472  ·  view source on GitHub ↗
(li, loose, inline, nl)

Source from the content-addressed store, hash-verified

447 // Add inline content `inline` to `li`. inline comes from processInline
448 // so is an array of content
449 function add(li, loose, inline, nl) {
450 if ( loose ) {
451 li.push( [ "para" ].concat(inline) );
452 return;
453 }
454 // Hmmm, should this be any block level element or just paras?
455 var add_to = li[li.length -1] instanceof Array && li[li.length - 1][0] == "para"
456 ? li[li.length -1]
457 : li;
458
459 // If there is already some content in this list, add the new line in
460 if ( nl && li.length > 1 ) inline.unshift(nl);
461
462 for ( var i = 0; i < inline.length; i++ ) {
463 var what = inline[i],
464 is_str = typeof what == "string";
465 if ( is_str && add_to.length > 1 && typeof add_to[add_to.length-1] == "string" ) {
466 add_to[ add_to.length-1 ] += what;
467 }
468 else {
469 add_to.push( what );
470 }
471 }
472 }
473
474 // contained means have an indent greater than the current one. On
475 // *every* line in the block

Callers 1

markdown.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected