Files: 1b789e63aa59f5d3e5539a4432c8b3c466977a0e / lib / markdownSummary.js
510 bytesRaw
1 | |
2 | exports.titleFromMarkdown = (text, max, maxLines) => { |
3 | if (text === null) { |
4 | return '' |
5 | } |
6 | text = text.trim().split('\n', maxLines + 1).join('\n') |
7 | text = text.replace(/_|`|\*|#|^\[@.*?]|\[|]|\(\S*?\)/g, '').trim() |
8 | text = text.replace(/:$/, '') |
9 | text = text.trim().split('\n', 1)[0].trim() |
10 | text = module.exports.truncate(text, max) |
11 | return text |
12 | } |
13 | |
14 | exports.truncate = (text, maxLength) => { |
15 | if (text.length > maxLength) { |
16 | text = text.substring(0, maxLength - 2) + '...' |
17 | } |
18 | return text |
19 | } |
20 |
Built with git-ssb-web