hyperdown 2.4.29 → 2.4.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Parser.js +36 -34
- package/package.json +1 -1
- package/src/Parser.coffee +33 -32
package/Parser.js
CHANGED
@@ -583,44 +583,46 @@
|
|
583
583
|
|
584
584
|
parseBlockTable(block, key, line, state, lines) {
|
585
585
|
var align, aligns, head, j, len, matches, row, rows;
|
586
|
-
if (!!(matches = line.match(
|
587
|
-
if (
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
head = 0;
|
593
|
-
if ((block == null) || block[0] !== 'normal' || lines[block[2]].match(/^\s*$/)) {
|
594
|
-
this.startBlock('table', key);
|
586
|
+
if (!!(matches = line.match(/^\s*(\|?[ :]*-{2,}[ :]*(?:[\|\+][ :]*-{2,}[ :]*)*\|?)\s*$/))) {
|
587
|
+
if (matches[1].indexOf('|') >= 0 || matches[1].indexOf('+') >= 0) {
|
588
|
+
if (this.isBlock('table')) {
|
589
|
+
block[3][0].push(block[3][2]);
|
590
|
+
block[3][2] += 1;
|
591
|
+
this.setBlock(key, block[3]);
|
595
592
|
} else {
|
596
|
-
head =
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
matches[1] = matches[1].substring(0, matches[1].length - 1);
|
593
|
+
head = 0;
|
594
|
+
if ((block == null) || block[0] !== 'normal' || lines[block[2]].match(/^\s*$/)) {
|
595
|
+
this.startBlock('table', key);
|
596
|
+
} else {
|
597
|
+
head = 1;
|
598
|
+
this.backBlock(1, 'table');
|
603
599
|
}
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
600
|
+
if (matches[1][0] === '|') {
|
601
|
+
matches[1] = matches[1].substring(1);
|
602
|
+
if (matches[1][matches[1].length - 1] === '|') {
|
603
|
+
matches[1] = matches[1].substring(0, matches[1].length - 1);
|
604
|
+
}
|
605
|
+
}
|
606
|
+
rows = matches[1].split(/\+|\|/);
|
607
|
+
aligns = [];
|
608
|
+
for (j = 0, len = rows.length; j < len; j++) {
|
609
|
+
row = rows[j];
|
610
|
+
align = 'none';
|
611
|
+
if (!!(matches = row.match(/^\s*(:?)\-+(:?)\s*$/))) {
|
612
|
+
if (!!matches[1] && !!matches[2]) {
|
613
|
+
align = 'center';
|
614
|
+
} else if (!!matches[1]) {
|
615
|
+
align = 'left';
|
616
|
+
} else if (!!matches[2]) {
|
617
|
+
align = 'right';
|
618
|
+
}
|
617
619
|
}
|
620
|
+
aligns.push(align);
|
618
621
|
}
|
619
|
-
|
622
|
+
this.setBlock(key, [[head], aligns, head + 1]);
|
620
623
|
}
|
621
|
-
|
624
|
+
return false;
|
622
625
|
}
|
623
|
-
return false;
|
624
626
|
}
|
625
627
|
return true;
|
626
628
|
}
|
@@ -649,7 +651,7 @@
|
|
649
651
|
}
|
650
652
|
|
651
653
|
parseBlockShr(block, key, line) {
|
652
|
-
if (!!(line.match(
|
654
|
+
if (!!(line.match(/^\*{3,}\s*$/))) {
|
653
655
|
this.startBlock('hr', key).endBlock();
|
654
656
|
return false;
|
655
657
|
}
|
@@ -657,7 +659,7 @@
|
|
657
659
|
}
|
658
660
|
|
659
661
|
parseBlockDhr(block, key, line) {
|
660
|
-
if (!!(line.match(
|
662
|
+
if (!!(line.match(/^-{3,}\s*$/))) {
|
661
663
|
this.startBlock('hr', key).endBlock();
|
662
664
|
return false;
|
663
665
|
}
|
package/package.json
CHANGED
package/src/Parser.coffee
CHANGED
@@ -613,45 +613,46 @@ class Parser
|
|
613
613
|
|
614
614
|
|
615
615
|
parseBlockTable: (block, key, line, state, lines) ->
|
616
|
-
if !!(matches = line.match
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
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 =
|
628
|
-
@backBlock 1, 'table'
|
623
|
+
head = 0
|
629
624
|
|
630
|
-
|
631
|
-
|
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][
|
634
|
-
matches[1] = matches[1].substring
|
631
|
+
if matches[1][0] == '|'
|
632
|
+
matches[1] = matches[1].substring 1
|
635
633
|
|
636
|
-
|
637
|
-
|
634
|
+
if matches[1][matches[1].length - 1] == '|'
|
635
|
+
matches[1] = matches[1].substring 0, matches[1].length - 1
|
638
636
|
|
639
|
-
|
640
|
-
|
637
|
+
rows = matches[1].split /\+|\|/
|
638
|
+
aligns = []
|
641
639
|
|
642
|
-
|
643
|
-
|
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
|
-
|
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
|
-
|
651
|
+
aligns.push align
|
653
652
|
|
654
|
-
|
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
|
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
|
696
|
+
if !!(line.match /^-{3,}\s*$/)
|
696
697
|
@startBlock 'hr', key
|
697
698
|
.endBlock()
|
698
699
|
|