{"action":"opened","issue":{"url":"https://api.github.com/repos/wizardforcel/dev-tutorial/issues/1","labels_url":"https://api.github.com/repos/wizardforcel/dev-tutorial/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/wizardforcel/dev-tutorial/issues/1/comments","events_url":"https://api.github.com/repos/wizardforcel/dev-tutorial/issues/1/events","html_url":"https://github.com/wizardforcel/dev-tutorial/issues/1","id":125736009,"number":1,"title":"genList.js","user":{"login":"wizardforcel","id":5080126,"avatar_url":"https://avatars.githubusercontent.com/u/5080126?v=3","gravatar_id":"","url":"https://api.github.com/users/wizardforcel","html_url":"https://github.com/wizardforcel","followers_url":"https://api.github.com/users/wizardforcel/followers","following_url":"https://api.github.com/users/wizardforcel/following{/other_user}","gists_url":"https://api.github.com/users/wizardforcel/gists{/gist_id}","starred_url":"https://api.github.com/users/wizardforcel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wizardforcel/subscriptions","organizations_url":"https://api.github.com/users/wizardforcel/orgs","repos_url":"https://api.github.com/users/wizardforcel/repos","events_url":"https://api.github.com/users/wizardforcel/events{/privacy}","received_events_url":"https://api.github.com/users/wizardforcel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-09T04:04:47Z","updated_at":"2016-01-09T04:04:47Z","closed_at":null,"body":"```javascript\r\nvar fs = require('fs');\r\n\r\nvar files = fs.readdirSync('D:\\\\blog\\\\source\\\\_posts');\r\n\r\nvar result = '';\r\n\r\nvar reTitle = /^title: (.+?)$/m;\r\nvar rePdf = /^[\\+\\-\\*]\\s+\\[PDF格式\\]\\(.+?\\)$/m;\r\nvar reEpub = /^[\\+\\-\\*]\\s+\\[EPUB格式\\]\\(.+?\\)$/m;\r\nvar reMobi = /^[\\+\\-\\*]\\s+\\[MOBI格式\\]\\(.+?\\)$/m;\r\nvar reDL = /^[\\+\\-\\*]\\s+\\[下载地址\\]\\(.+?\\)$/m;\r\nvar reOL = /^[\\+\\-\\*]\\s+\\[在线阅读\\]\\(.+?\\)$/m;\r\n\r\nfor(var i in files)\r\n{\r\n\tvar fName = files[i];\r\n\tif(!fName.endsWith('.md'))\r\n\t\tcontinue;\r\n\tconsole.log(fName);\r\n\tvar content = fs.readFileSync('D:\\\\blog\\\\source\\\\_posts\\\\' + fName, 'utf-8');\r\n\t\r\n\tvar rmTitle = content.match(reTitle);\r\n\tif(!rmTitle) continue;\r\n\tvar title = rmTitle[1];\r\n\t\r\n\tvar links = '';\r\n\t\r\n\tvar rmOL = content.match(reOL);\r\n\tvar olLink = rmOL? rmOL[0] + '\\n': '';\r\n\tlinks += olLink;\r\n\t\r\n\tvar rmPdf = content.match(rePdf);\r\n\tvar pdfLink = rmPdf? rmPdf[0] + '\\n': '';\r\n\tlinks += pdfLink;\r\n\t\r\n\tvar rmEpub = content.match(reEpub);\r\n\tvar epubLink = rmEpub? rmEpub[0] + '\\n': '';\r\n\tlinks += epubLink;\r\n\t\r\n\tvar rmMobi = content.match(reMobi);\r\n\tvar mobiLink = rmMobi? rmMobi[0] + '\\n': '';\r\n\tlinks += mobiLink;\r\n\t\r\n\tvar rmDL = content.match(reDL);\r\n\tvar dLink = rmDL? rmDL[0] + '\\n': '';\r\n\tlinks += dLink;\r\n\t\r\n\tif(links == '')\r\n\t\tcontinue;\r\n\t\r\n\tresult += '# ' + title + '\\n\\n';\r\n\tresult += links;\r\n\tresult += '\\n';\r\n}\r\n\r\nfs.writeFileSync('result.md', result);\r\n```"}}