Skip to content

Commit

Permalink
chore: add eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
benjycui committed Feb 4, 2016
1 parent c65b44d commit cbde745
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "eslint-config-egg"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules/
/npm-debug.log
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@
"description": "Parse Markdown into JavaScript object.",
"main": "index.js",
"scripts": {
"test": "mocha"
"test": "mocha",
"lint": "eslint ./index.js ./src",
"eslint-fix": "eslint --fix ./index.js ./src"
},
"keywords": [
"markdown",
"parser"
],
"author": "Benjy Cui",
"author": "Benjy Cui <[email protected]>",
"license": "MIT",
"dependencies": {
"marked": "^0.3.5"
},
"devDependencies": {
"eslint": "^1.10.3",
"eslint-config-egg": "^1.0.3"
}
}
38 changes: 19 additions & 19 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ class Parser {
parseElement() {
const token = this.token;
switch (token.type) {
case 'hr': return {type: 'hr'};
case 'heading': return this.parseHeading(token);
case 'code': return this.parseCode(token);
case 'table': return null; // TODO
case 'blockquote_start': return this.parseBlockquote(token);
case 'list_start': return this.parseList(token);
case 'list_item_start':
case 'loose_item_start': return this.parseListItem(token);
case 'html': return {type: 'html', children: token.text};
case 'paragraph': return this.parseParagraph(token);
case 'text': return this.parseText(token);
default: return null;
case 'hr': return {type: 'hr'};
case 'heading': return this.parseHeading(token);
case 'code': return this.parseCode(token);
case 'table': return null; // TODO
case 'blockquote_start': return this.parseBlockquote(token);
case 'list_start': return this.parseList(token);
case 'list_item_start':
case 'loose_item_start': return this.parseListItem(token);
case 'html': return {type: 'html', children: token.text};
case 'paragraph': return this.parseParagraph(token);
case 'text': return this.parseText(token);
default: return null;
}
}

Expand All @@ -63,14 +63,14 @@ class Parser {
return {
type: 'code',
props: {lang: token.lang},
children: token.text
children: token.text,
};
}

parseBlockquote() {
const blockquote = {
type: 'blockquote',
children: []
children: [],
};

while (this.next().type !== 'blockquote_end') {
Expand All @@ -83,7 +83,7 @@ class Parser {
parseList(token) {
const list = {
type: token.ordered ? 'ol' : 'ul',
children: []
children: [],
};

while (this.next().type !== 'list_end') {
Expand All @@ -96,8 +96,8 @@ class Parser {
parseListItem() {
const listItem = {
type: 'li',
children: []
}
children: [],
};

while (this.next().type !== 'list_item_end') {
listItem.children.push(this.parseElement());
Expand All @@ -109,7 +109,7 @@ class Parser {
parseParagraph(token) {
return {
type: 'p',
children: marked.inlineLexer(token.text, this.links) // TODO
children: marked.inlineLexer(token.text, this.links), // TODO
};
}

Expand All @@ -122,7 +122,7 @@ class Parser {

return {
type: 'span',
children: marked.inlineLexer(text, this.links) // TODO
children: marked.inlineLexer(text, this.links), // TODO
};
}
}
Expand Down

0 comments on commit cbde745

Please sign in to comment.