Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiang Shang committed Sep 2, 2015
1 parent 33e2762 commit 304706d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 21 deletions.
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hyperdown",
"version": "0.1.3",
"version": "0.1.4",
"repo": "segmentfault/hyperdown.js",
"description": "A markdown parser",
"keywords": ["markdown", "hyperdown", "html"],
Expand Down
6 changes: 3 additions & 3 deletions dist/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ var Parser = (function () {
head = true;
this.backBlock(1, 'table');
}
console.log(tableMatches);

if (tableMatches[1][0] == '|') {
tableMatches[1] = tableMatches[1].substr(1);

Expand Down Expand Up @@ -919,7 +919,7 @@ var Parser = (function () {

var _loop = function (key) {
var line = lines[key];
if (key === ignore) {
if (parseInt(key) === ignore) {
head = false;
body = true;
return 'continue';
Expand All @@ -933,7 +933,7 @@ var Parser = (function () {
line = line.substr(1);

if (line[line.length - 1] === '|') {
line = line.substr(0, -1);
line = line.slice(0, -1);
}
}

Expand Down
9 changes: 2 additions & 7 deletions hyperdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@
var space = _row[0];
var type = _row[1];
var line = _row[2];
var _text = _row[3];
var text = _row[3];

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

leftLines = [_text];
leftLines = [text];
lastType = type;
}
} else {
Expand Down Expand Up @@ -1342,11 +1342,6 @@
})();

exports['default'] = Parser;

var parser = new Parser();
var text = '| Item | Value | Qty |\n| :-------- | --------:| :--: |\n| Computer | 1600 USD | 5 |\n| Phone | 12 USD | 12 |\n| Pipe | 1 USD | 234 |';

console.log(parser.makeHtml(text));
module.exports = exports['default'];

/***/ },
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Markdown解析器",
"repository": "https://github.com/SegmentFault/HyperDown.js",
"license": "BSD-4-Clause",
"version": "0.1.3",
"version": "0.1.4",
"devDependencies": {
"babel": "^5.8.22",
"babel-core": "^5.8.22",
Expand Down
8 changes: 0 additions & 8 deletions src/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1050,11 +1050,3 @@ export default class Parser {
return this
}
}
var parser = new Parser()
var text = `| Item | Value | Qty |
| :-------- | --------:| :--: |
| Computer | 1600 USD | 5 |
| Phone | 12 USD | 12 |
| Pipe | 1 USD | 234 |`

console.log(parser.makeHtml(text))
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('HyperDown.js', function() {
assert.equal('<table><tbody><tr><td>test</td><td>test</td><tr></tbody></table>', parser.makeHtml('<table><tbody><tr><td>test</td><td>test</td><tr></tbody></table>'));
});
it('type2 |', function() {
assert.equal('<table><thead><tr><th>test</th><th>test</th></tr></thead><thead><tr><th>------</th><th colspan="2">------</th></tr></thead><thead><tr><th>test</th><th>test</th></tr></thead></tbody></table>',
assert.equal('<table><thead><tr><th align="left">Item</th><th>Value</th><th align="right">Qty</th></tr></thead><tbody><tr><td align="left">Computer</td><td>1600 USD</td><td align="right">5</td></tr><tr><td align="left">Phone</td><td>12 USD</td><td align="right">12</td></tr><tr><td align="left">Pipe</td><td>1 USD</td><td align="right">234</td></tr></tbody></table>',
parser.makeHtml('| Item | Value | Qty |\n| :-------- | --------:| :--: |\n| Computer | 1600 USD | 5 |\n| Phone | 12 USD | 12 |\n| Pipe | 1 USD | 234 |'));
});
});
Expand Down

0 comments on commit 304706d

Please sign in to comment.