Skip to content

Commit

Permalink
Issue braziljs#5 - Outline
Browse files Browse the repository at this point in the history
  • Loading branch information
RenatoSiqueira committed Oct 8, 2018
1 parent 520eba8 commit d662b15
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions classes/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
}
10 changes: 10 additions & 0 deletions classes/weekly.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
}

0 comments on commit d662b15

Please sign in to comment.