1module.exports = extractDescription
2
3// Extracts description from contents of a readme file in markdown format
4function extractDescription (d) {
5  if (!d) {
6    return
7  }
8  if (d === 'ERROR: No README data found!') {
9    return
10  }
11  // the first block of text before the first heading
12  // that isn't the first line heading
13  d = d.trim().split('\n')
14  let s = 0
15  while (d[s] && d[s].trim().match(/^(#|$)/)) {
16    s++
17  }
18  const l = d.length
19  let e = s + 1
20  while (e < l && d[e].trim()) {
21    e++
22  }
23  return d.slice(s, e).join(' ').trim()
24}
25