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 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 (this.isBlock('table')) {
588
- block[3][0].push(block[3][2]);
589
- block[3][2] += 1;
590
- this.setBlock(key, block[3]);
591
- } else {
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 = 1;
597
- this.backBlock(1, 'table');
598
- }
599
- if (matches[1][0] === '|') {
600
- matches[1] = matches[1].substring(1);
601
- if (matches[1][matches[1].length - 1] === '|') {
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
- rows = matches[1].split(/\+|\|/);
606
- aligns = [];
607
- for (j = 0, len = rows.length; j < len; j++) {
608
- row = rows[j];
609
- align = 'none';
610
- if (!!(matches = row.match(/^\s*(:?)\-+(:?)\s*$/))) {
611
- if (!!matches[1] && !!matches[2]) {
612
- align = 'center';
613
- } else if (!!matches[1]) {
614
- align = 'left';
615
- } else if (!!matches[2]) {
616
- align = 'right';
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
- aligns.push(align);
622
+ this.setBlock(key, [[head], aligns, head + 1]);
620
623
  }
621
- this.setBlock(key, [[head], aligns, head + 1]);
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(/^(\* *){3,}\s*$/))) {
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(/^(- *){3,}\s*$/))) {
662
+ if (!!(line.match(/^-{3,}\s*$/))) {
661
663
  this.startBlock('hr', key).endBlock();
662
664
  return false;
663
665
  }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "license": "BSD-4-Clause",
9
9
  "author": "SegmentFault",
10
- "version": "2.4.29",
10
+ "version": "2.4.31",
11
11
  "scripts": {
12
12
  "test": "mocha",
13
13
  "build": "cake build"
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
- 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