@@ -613,45 +613,46 @@ class Parser
613
613
614
614
615
615
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 ]
626
622
else
627
- head = 1
628
- @ backBlock 1 , ' table'
623
+ head = 0
629
624
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'
632
630
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
635
633
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
638
636
639
- for row in rows
640
- align = ' none '
637
+ rows = matches[ 1 ]. split / \+ | \| /
638
+ aligns = []
641
639
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'
649
642
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'
651
650
652
- @ setBlock key, [[head], aligns, head + 1 ]
651
+ aligns . push align
653
652
654
- return no
653
+ @ setBlock key, [[head], aligns, head + 1 ]
654
+
655
+ return no
655
656
656
657
yes
657
658
@@ -682,7 +683,7 @@ class Parser
682
683
683
684
684
685
parseBlockShr : (block , key , line ) ->
685
- if !! (line .match / ^ ( \* * ) {3,} \s * $ / )
686
+ if !! (line .match / ^ \* {3,} \s * $ / )
686
687
@ startBlock ' hr' , key
687
688
.endBlock ()
688
689
@@ -692,7 +693,7 @@ class Parser
692
693
693
694
694
695
parseBlockDhr : (block , key , line ) ->
695
- if !! (line .match / ^ (- * ) {3,} \s * $ / )
696
+ if !! (line .match / ^ - {3,} \s * $ / )
696
697
@ startBlock ' hr' , key
697
698
.endBlock ()
698
699
0 commit comments