| 66 | } |
| 67 | |
| 68 | formatChat (chat) { |
| 69 | let content = __guard__(chat.get('message'), x => x.text) || '' |
| 70 | content = content.replace(/^\|Free\|?:? ?(.*?)$/gm, '$1') |
| 71 | content = content.replace(/^\|Issue\|?:? ?(.*?)$/gm, '\n$1') |
| 72 | content = content.replace(/^\|Explanation\|?:? ?(.*?)$/gm, '\n*$1*\n') |
| 73 | content = content.replace(/\|Code\|?:? ?\n?```\n?((.|\n)*?)```\n?/g, (match, p1) => { |
| 74 | return '[Show Me]' |
| 75 | }) |
| 76 | content = content.trim() |
| 77 | content = marked(content, { gfm: true, breaks: true }) |
| 78 | content = content.replace(RegExp(' {2}', 'g'), ' ') // coffeescript can't compile '/ /g' |
| 79 | // Replace any <p><code>...</code></p> with <pre><code>...</code></pre> |
| 80 | content = content.replace(/<p><code>((.|\n)*?)(?:(?!<\/code>)(.|\n))*?<\/code><\/p>/g, match => match.replace(/<p><code>/g, '<pre><code>').replace(/<\/code><\/p>/g, '</code></pre>')) |
| 81 | content = content.replace(/\[Show Me\]/g, '<p><button class="btn btn-illustrated btn-small btn-primary fix-code-button">Show Me</button></p>') |
| 82 | return content |
| 83 | } |
| 84 | } |
| 85 | ChatSearchView.initClass() |
| 86 | return ChatSearchView |