Skip to content

Commit 33e2762

Browse files
author
Jiang Shang
committed
v0.1.3
1 parent d6268e3 commit 33e2762

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

component.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hyperdown",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"repo": "segmentfault/hyperdown.js",
55
"description": "A markdown parser",
66
"keywords": ["markdown", "hyperdown", "html"],

hyperdown.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@
895895
var space = _row[0];
896896
var type = _row[1];
897897
var line = _row[2];
898-
var text = _row[3];
898+
var _text = _row[3];
899899

900900
if (space !== minSpace) {
901901
var pattern = new RegExp("^\s{" + secondMinSpace + "}");
@@ -913,7 +913,7 @@
913913
html += "<li>" + this.parse(leftLines.join("\n")) + "</li>";
914914
}
915915

916-
leftLines = [text];
916+
leftLines = [_text];
917917
lastType = type;
918918
}
919919
} else {
@@ -965,7 +965,7 @@
965965

966966
var _loop = function (key) {
967967
var line = lines[key];
968-
if (key === ignore) {
968+
if (parseInt(key) === ignore) {
969969
head = false;
970970
body = true;
971971
return 'continue';
@@ -979,7 +979,7 @@
979979
line = line.substr(1);
980980

981981
if (line[line.length - 1] === '|') {
982-
line = line.substr(0, -1);
982+
line = line.slice(0, -1);
983983
}
984984
}
985985

@@ -1342,6 +1342,11 @@
13421342
})();
13431343

13441344
exports['default'] = Parser;
1345+
1346+
var parser = new Parser();
1347+
var text = '| Item | Value | Qty |\n| :-------- | --------:| :--: |\n| Computer | 1600 USD | 5 |\n| Phone | 12 USD | 12 |\n| Pipe | 1 USD | 234 |';
1348+
1349+
console.log(parser.makeHtml(text));
13451350
module.exports = exports['default'];
13461351

13471352
/***/ },

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Markdown解析器",
44
"repository": "https://github.com/SegmentFault/HyperDown.js",
55
"license": "BSD-4-Clause",
6-
"version": "0.1.2",
6+
"version": "0.1.3",
77
"devDependencies": {
88
"babel": "^5.8.22",
99
"babel-core": "^5.8.22",

src/Parser.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ export default class Parser {
753753

754754
for (let key in lines) {
755755
let line = lines[key]
756-
if (key === ignore) {
756+
if (parseInt(key) === ignore) {
757757
head = false
758758
body = true
759759
continue
@@ -767,7 +767,7 @@ export default class Parser {
767767
line = line.substr(1)
768768

769769
if (line[line.length - 1] === '|') {
770-
line = line.substr(0, -1)
770+
line = line.slice(0, -1)
771771
}
772772
}
773773

@@ -1050,3 +1050,11 @@ export default class Parser {
10501050
return this
10511051
}
10521052
}
1053+
var parser = new Parser()
1054+
var text = `| Item | Value | Qty |
1055+
| :-------- | --------:| :--: |
1056+
| Computer | 1600 USD | 5 |
1057+
| Phone | 12 USD | 12 |
1058+
| Pipe | 1 USD | 234 |`
1059+
1060+
console.log(parser.makeHtml(text))

0 commit comments

Comments
 (0)