git ssb

1+

Daan Patchwork / patchwork



Tree: 401c797bb92a373ffa4499d47ecea37f75e2a16e

Files: 401c797bb92a373ffa4499d47ecea37f75e2a16e / 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