diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-22 22:31:47 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-22 22:31:47 +0100 |
commit | 74ea419c530921374ffbe893f01b6a4695995349 (patch) | |
tree | eb58ec1c960f2747831cfae0dcee2d0447b3705a /lib/utils | |
parent | 0c8513801c131ec6e2c7b348403a4c66a9bf2a11 (diff) | |
download | gitbook-74ea419c530921374ffbe893f01b6a4695995349.zip gitbook-74ea419c530921374ffbe893f01b6a4695995349.tar.gz gitbook-74ea419c530921374ffbe893f01b6a4695995349.tar.bz2 |
Write search index to output folder
Diffstat (limited to 'lib/utils')
-rw-r--r-- | lib/utils/page.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/utils/page.js b/lib/utils/page.js index 0168831..525722e 100644 --- a/lib/utils/page.js +++ b/lib/utils/page.js @@ -139,6 +139,21 @@ function normalizePage(sections, options) { }); }; +// Extract text from sections +function extractText(sections) { + return _.reduce(sections, function(prev, section) { + if (section.type != "normal") return prev; + + var $ = cheerio.load(section.content); + $("*").each(function() { + prev = prev+" "+$(this).text(); + }); + + return prev; + }, ""); +}; + module.exports = { - normalize: normalizePage + normalize: normalizePage, + extractText: extractText }; |