git ssb

1+

Daan Patchwork / patchwork



Tree: d410e696e202f0fa3b384dfa76ad876acb28868b

Files: d410e696e202f0fa3b384dfa76ad876acb28868b / 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