summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-asciidoc/lib/glossary.js
blob: e3f51bded1e3af5d11497b323c07c7f5545b26bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var _ = require('lodash');
var cheerio = require('cheerio');

var convert = require('./utils/convert');

function parseGlossary(src) {
	var html = convert(src);
    $ = cheerio.load(html);

    var entries = [];

    $("h2").each(function() {
    	var $h2 = $(this);
        var $p = $h2.next().find("p");

    	var entry = {};

    	entry.name = $h2.text();
        entry.description = $p.text();

    	entries.push(entry);
    });

    return entries;
}

module.exports = parseGlossary;