@@ -613,45 +613,46 @@ class Parser
613613
614614
615615 parseBlockTable : (block , key , line , state , lines ) ->
616- if !! (matches = line .match / ^ \s * (\| ? [ :] * -+ [ :] * (?:\| [ :] * -+ [ :] * )* \| ? )\s * $ / )
617- if @ isBlock ' table'
618- block[3 ][0 ].push block[3 ][2 ]
619- block[3 ][2 ] += 1
620- @ setBlock key, block[3 ]
621- else
622- head = 0
623-
624- if not block? or block[0 ] != ' normal' or lines[block[2 ]].match / ^ \s * $ /
625- @ startBlock ' table' , key
616+ if !! (matches = line .match / ^ \s * (\| ? [ :] * -{2,} [ :] * (?:[\|\+ ][ :] * -{2,} [ :] * )* \| ? )\s * $ / )
617+ if matches[1 ].indexOf (' |' ) >= 0 or matches[1 ].indexOf (' +' ) >= 0
618+ if @ isBlock ' table'
619+ block[3 ][0 ].push block[3 ][2 ]
620+ block[3 ][2 ] += 1
621+ @ setBlock key, block[3 ]
626622 else
627- head = 1
628- @ backBlock 1 , ' table'
623+ head = 0
629624
630- if matches[1 ][0 ] == ' |'
631- matches[1 ] = matches[1 ].substring 1
625+ if not block? or block[0 ] != ' normal' or lines[block[2 ]].match / ^ \s * $ /
626+ @ startBlock ' table' , key
627+ else
628+ head = 1
629+ @ backBlock 1 , ' table'
632630
633- if matches[1 ][matches[ 1 ]. length - 1 ] == ' |'
634- matches[1 ] = matches[1 ].substring 0 , matches[ 1 ]. length - 1
631+ if matches[1 ][0 ] == ' |'
632+ matches[1 ] = matches[1 ].substring 1
635633
636- rows = matches[1 ]. split / \+ | \| /
637- aligns = []
634+ if matches[1 ][matches[ 1 ]. length - 1 ] == ' | '
635+ matches[ 1 ] = matches[ 1 ]. substring 0 , matches[ 1 ]. length - 1
638636
639- for row in rows
640- align = ' none '
637+ rows = matches[ 1 ]. split / \+ | \| /
638+ aligns = []
641639
642- if !! (matches = row .match / ^ \s * (:? )\- + (:? )\s * $ / )
643- if !! matches[1 ] && !! matches[2 ]
644- align = ' center'
645- else if !! matches[1 ]
646- align = ' left'
647- else if !! matches[2 ]
648- align = ' right'
640+ for row in rows
641+ align = ' none'
649642
650- aligns .push align
643+ if !! (matches = row .match / ^ \s * (:? )\- + (:? )\s * $ / )
644+ if !! matches[1 ] && !! matches[2 ]
645+ align = ' center'
646+ else if !! matches[1 ]
647+ align = ' left'
648+ else if !! matches[2 ]
649+ align = ' right'
651650
652- @ setBlock key, [[head], aligns, head + 1 ]
651+ aligns . push align
653652
654- return no
653+ @ setBlock key, [[head], aligns, head + 1 ]
654+
655+ return no
655656
656657 yes
657658
@@ -682,7 +683,7 @@ class Parser
682683
683684
684685 parseBlockShr : (block , key , line ) ->
685- if !! (line .match / ^ ( \* * ) {3,} \s * $ / )
686+ if !! (line .match / ^ \* {3,} \s * $ / )
686687 @ startBlock ' hr' , key
687688 .endBlock ()
688689
@@ -692,7 +693,7 @@ class Parser
692693
693694
694695 parseBlockDhr : (block , key , line ) ->
695- if !! (line .match / ^ (- * ) {3,} \s * $ / )
696+ if !! (line .match / ^ - {3,} \s * $ / )
696697 @ startBlock ' hr' , key
697698 .endBlock ()
698699
0 commit comments