git ssb

1+

Daan Patchwork / patchwork



Tree: 58ab0241031aa549a35cce1e678c27065ae66221

Files: 58ab0241031aa549a35cce1e678c27065ae66221 / 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