@@ -570,9 +570,10 @@ var Parser = (function () {
570570 // normal
571571 default :
572572 if ( this . isBlock ( 'list' ) ) {
573- var _matches = line . match ( / ^ ( \s * ) / ) ;
574-
575- if ( line . length == _matches [ 1 ] . length ) {
573+ // let matches = line.match(/^(\s*)/)
574+ //
575+ // if (line.length == matches[1].length) { // empty line
576+ if ( / ^ ( \s * ) / . test ( line ) ) {
576577 // empty line
577578 if ( emptyCount > 0 ) {
578579 this . startBlock ( 'normal' , key ) ;
@@ -587,9 +588,9 @@ var Parser = (function () {
587588 this . startBlock ( 'normal' , key ) ;
588589 }
589590 } else if ( this . isBlock ( 'footnote' ) ) {
590- var _matches2 = line . match ( / ^ ( \s * ) / ) ;
591+ var _matches = line . match ( / ^ ( \s * ) / ) ;
591592
592- if ( _matches2 [ 1 ] . length >= this . getBlock ( ) [ 3 ] [ 0 ] ) {
593+ if ( _matches [ 1 ] . length >= this . getBlock ( ) [ 3 ] [ 0 ] ) {
593594 this . setBlock ( key ) ;
594595 } else {
595596 this . startBlock ( 'normal' , key ) ;
@@ -613,10 +614,19 @@ var Parser = (function () {
613614 this . startBlock ( 'normal' , key ) ;
614615 }
615616 } else if ( this . isBlock ( 'quote' ) ) {
616- if ( / ^ \s * $ / . test ( line ) ) {
617- this . startBlock ( 'normal' , key ) ;
618- } else {
617+ if ( / ^ ( \s * ) / . test ( line ) ) {
618+ // empty line
619+ if ( emptyCount > 0 ) {
620+ this . startBlock ( 'normal' , key ) ;
621+ } else {
622+ this . setBlock ( key ) ;
623+ }
624+
625+ emptyCount ++ ;
626+ } else if ( $emptyCount == 0 ) {
619627 this . setBlock ( key ) ;
628+ } else {
629+ this . startBlock ( 'normal' , key ) ;
620630 }
621631 } else {
622632 var block = this . getBlock ( ) ;
@@ -664,11 +674,13 @@ var Parser = (function () {
664674 }
665675
666676 if ( 'normal' === type ) {
667- // combine two splitted list
677+ // combine two blocks
678+ var types = [ 'list' , 'quote' ] ;
679+
668680 if ( from === to && lines [ from ] . match ( / ^ \s * $ / ) && prevBlock && nextBlock ) {
669- if ( prevBlock [ 0 ] === 'list' && nextBlock [ 0 ] === 'list' ) {
681+ if ( prevBlock [ 0 ] == nextBlock [ 0 ] && types . indexOf ( prevBlock [ 0 ] !== - 1 ) ) {
670682 // combine 3 blocks
671- blocks [ key - 1 ] = [ 'list' , prevBlock [ 1 ] , nextBlock [ 2 ] , null ] ;
683+ blocks [ key - 1 ] = [ prevBlock [ 0 ] , prevBlock [ 1 ] , nextBlock [ 2 ] , NULL ] ;
672684 blocks . splice ( key , 2 ) ;
673685 }
674686 }
@@ -777,7 +789,6 @@ var Parser = (function () {
777789 } , {
778790 key : 'parseQuote' ,
779791 value : function parseQuote ( lines ) {
780- console . log ( lines ) ;
781792 lines . forEach ( function ( line , key ) {
782793 lines [ key ] = line . replace ( / ^ \s * > ? / , '' ) ;
783794 } ) ;
@@ -1248,7 +1259,4 @@ var Parser = (function () {
12481259} ) ( ) ;
12491260
12501261exports [ 'default' ] = Parser ;
1251-
1252- var parser = new Parser ( ) ;
1253- console . log ( parser . makeHtml ( '>1234\n1234' ) ) ;
12541262module . exports = exports [ 'default' ] ;
0 commit comments