• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1module.exports = extractDescription
2
3// Extracts description from contents of a readme file in markdown format
4function extractDescription (d) {
5  if (!d) return;
6  if (d === "ERROR: No README data found!") return;
7  // the first block of text before the first heading
8  // that isn't the first line heading
9  d = d.trim().split('\n')
10  for (var s = 0; d[s] && d[s].trim().match(/^(#|$)/); s ++);
11  var l = d.length
12  for (var e = s + 1; e < l && d[e].trim(); e ++);
13  return d.slice(s, e).join(' ').trim()
14}
15