summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-html/src/readme.js
blob: 18b0e6278f5642f94400352d4a57d2b6ecaacacc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const dom = require('./dom');

/**
 * Parse an HTML content into metadata about a readme
 *
 * @param {String} html
 * @return {Object}
 */
function parseReadme(html) {
    const $ = dom.parse(html);

    return {
        title: $('h1:first-child').text().trim(),
        description: $('div.paragraph,p').first().text().trim()
    };
}

module.exports = parseReadme;