Skip to content

Commit 2408abd

Browse files
author
Jiang Shang
committed
quote 多行支持
1 parent c84a951 commit 2408abd

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

dist/Parser.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd
2020

2121
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
2222

23+
require('babel-core/polyfill');
24+
2325
var _md5 = require('md5');
2426

2527
var _md52 = _interopRequireDefault(_md5);
@@ -610,6 +612,12 @@ var Parser = (function () {
610612
} else {
611613
this.startBlock('normal', key);
612614
}
615+
} else if (this.isBlock('quote')) {
616+
if (/^\s*$/.test(line)) {
617+
this.startBlock('normal', key);
618+
} else {
619+
this.setBlock(key);
620+
}
613621
} else {
614622
var block = this.getBlock();
615623
if (block === null || block.length === 0 || block[0] !== 'normal') {
@@ -769,6 +777,7 @@ var Parser = (function () {
769777
}, {
770778
key: 'parseQuote',
771779
value: function parseQuote(lines) {
780+
console.log(lines);
772781
lines.forEach(function (line, key) {
773782
lines[key] = line.replace(/^\s*> ?/, '');
774783
});
@@ -1239,4 +1248,7 @@ var Parser = (function () {
12391248
})();
12401249

12411250
exports['default'] = Parser;
1251+
1252+
var parser = new Parser();
1253+
console.log(parser.makeHtml('>1234\n1234'));
12421254
module.exports = exports['default'];

hyperdown.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,12 @@
658658
} else {
659659
this.startBlock('normal', key);
660660
}
661+
} else if (this.isBlock('quote')) {
662+
if (/^\s*$/.test(line)) {
663+
this.startBlock('normal', key);
664+
} else {
665+
this.setBlock(key);
666+
}
661667
} else {
662668
var block = this.getBlock();
663669
if (block === null || block.length === 0 || block[0] !== 'normal') {
@@ -817,6 +823,7 @@
817823
}, {
818824
key: 'parseQuote',
819825
value: function parseQuote(lines) {
826+
console.log(lines);
820827
lines.forEach(function (line, key) {
821828
lines[key] = line.replace(/^\s*> ?/, '');
822829
});
@@ -1287,6 +1294,9 @@
12871294
})();
12881295

12891296
exports['default'] = Parser;
1297+
1298+
var parser = new Parser();
1299+
console.log(parser.makeHtml('>1234\n1234'));
12901300
module.exports = exports['default'];
12911301

12921302
/***/ },

src/Parser.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,12 @@ export default class Parser {
555555
} else {
556556
this.startBlock('normal', key)
557557
}
558+
} else if (this.isBlock('quote')) {
559+
if (/^\s*$/.test(line)) {
560+
this.startBlock('normal', key)
561+
} else {
562+
this.setBlock(key)
563+
}
558564
} else {
559565
let block = this.getBlock()
560566
if (block === null || block.length === 0 || block[0] !== 'normal') {
@@ -691,6 +697,7 @@ export default class Parser {
691697
* @return string
692698
*/
693699
parseQuote(lines) {
700+
console.log(lines)
694701
lines.forEach( (line, key) => {
695702
lines[key] = line.replace(/^\s*> ?/, '')
696703
})
@@ -1082,3 +1089,5 @@ export default class Parser {
10821089
return this
10831090
}
10841091
}
1092+
var parser = new Parser()
1093+
console.log(parser.makeHtml('>1234\n1234'))

0 commit comments

Comments
 (0)