diff --git a/classes/comment.js b/classes/comment.js index 61fb70e..cb246ad 100644 --- a/classes/comment.js +++ b/classes/comment.js @@ -26,8 +26,7 @@ class Comment { applyCategory () { let cat = this.mdBody.match(/[\n\r][\*_](.+)[\*_]$/m) - cat = cat ? cat[1] : 'Outros' - let testCat = cat.toLowerCase() + let testCat = cat[1].toLowerCase() if (testCat.match(/(new|not.cia|novidade|an.nci|announc)/)) { cat = "Notícias" @@ -39,7 +38,10 @@ class Comment { cat = "Vídeos" } else if (testCat.match(/(tool|demo|experiment|ferrament)/)) { cat = "Demos e Ferramentas" + } else { + cat = 'Outros' } + this.category = cat } } diff --git a/classes/weekly.js b/classes/weekly.js index a6d78b2..8f1a2ab 100644 --- a/classes/weekly.js +++ b/classes/weekly.js @@ -47,6 +47,10 @@ class Weekly { Github.get('comments', { issue: this.number }) .then(comments => { comments.forEach(data => { + + if(data.body.charAt(0) !== '*') + data.body = this.applyMarkdown(data.body) + this.addComment(new Comment(data)) }) resolve(this) @@ -58,4 +62,10 @@ class Weekly { this.categories[comment.category] = this.categories[comment.category] || [] this.categories[comment.category].push(comment) } + applyMarkdown (item){ + item = item.replace(/^\[/, '**[') + item = item.replace(/\)/, ')**') + item = item.trim().replace(/(.+\w)$/, '*$1*') + return item + } }