git ssb

1+

Daan Patchwork / patchwork



Tree: bfad9d94f6fd6b6ee044e8305e9ce1f7bc1dc32b

Files: bfad9d94f6fd6b6ee044e8305e9ce1f7bc1dc32b / lib / markdownSummary.js

510 bytesRaw
1
2exports.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
14exports.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