Last active
          June 14, 2022 12:36 
        
      - 
      
- 
        Save mikeal/e87fae29728fea1761b7 to your computer and use it in GitHub Desktop. 
Revisions
- 
        mikeal revised this gist Feb 27, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ var highlight = require('highlight.js') var cheerio = require('cheerio') var strip = ['/', '#', ' ', '*', "<", ">", '-', '\\'] function getComments (str) { var html = highlight.highlightAuto(str).value 
- 
        mikeal created this gist Feb 27, 2016 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ var highlight = require('highlight.js') var cheerio = require('cheerio') var strip = ['/', '#', ' ', '*', "<", ">", '-', '\'] function getComments (str) { var html = highlight.highlightAuto(str).value var $ = cheerio.load(html) var lines = $('span.hljs-comment').map(function(i, el) {return $(this).text();}).get() return lines.map(function (l) { while (l.length && strip.indexOf(l[0]) !== -1) { l = l.slice(1) } return l }) } module.exports = getComments