mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
PR-URL: https://github.com/nodejs/node/pull/39813 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
23 lines
547 B
JavaScript
23 lines
547 B
JavaScript
module.exports = extractDescription
|
|
|
|
// Extracts description from contents of a readme file in markdown format
|
|
function extractDescription (d) {
|
|
if (!d) {
|
|
return
|
|
}
|
|
if (d === 'ERROR: No README data found!') {
|
|
return
|
|
}
|
|
// the first block of text before the first heading
|
|
// that isn't the first line heading
|
|
d = d.trim().split('\n')
|
|
for (var s = 0; d[s] && d[s].trim().match(/^(#|$)/); s++) {
|
|
;
|
|
}
|
|
var l = d.length
|
|
for (var e = s + 1; e < l && d[e].trim(); e++) {
|
|
;
|
|
}
|
|
return d.slice(s, e).join(' ').trim()
|
|
}
|