diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-20 16:56:07 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-12-22 12:32:15 +0100 |
commit | 5b88703e83965f54edaf0f56f5f00d41fab33853 (patch) | |
tree | b7c41a20669240cf10102ee75fd238635bb433b2 /packages/gitbook-html/lib | |
parent | d282447802394051a1208371ddc99e9bdb841619 (diff) | |
download | gitbook-5b88703e83965f54edaf0f56f5f00d41fab33853.zip gitbook-5b88703e83965f54edaf0f56f5f00d41fab33853.tar.gz gitbook-5b88703e83965f54edaf0f56f5f00d41fab33853.tar.bz2 |
Parse title for parts
Diffstat (limited to 'packages/gitbook-html/lib')
-rwxr-xr-x | packages/gitbook-html/lib/summary.js | 6 | ||||
-rw-r--r-- | packages/gitbook-html/lib/totext.js | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/packages/gitbook-html/lib/summary.js b/packages/gitbook-html/lib/summary.js index 9b6b688..132dfdd 100755 --- a/packages/gitbook-html/lib/summary.js +++ b/packages/gitbook-html/lib/summary.js @@ -1,7 +1,7 @@ var _ = require('lodash'); var dom = require('./dom'); -var SELECTOR_LIST = '.olist > ol, ol, ul'; +var SELECTOR_LIST = 'ol, ul'; var SELECTOR_LINK = '> a, p > a'; var BL = '\n'; @@ -54,9 +54,11 @@ function parseSummary(html) { $lists.each(function() { var $list = $(this); + var $title = $list.prevUntil(SELECTOR_LIST, 'h2, h3, h4').first(); parts.push({ - articles: parseList($(SELECTOR_LIST).first(), $) + title: $title.text().trim(), + articles: parseList($list, $) }); }); diff --git a/packages/gitbook-html/lib/totext.js b/packages/gitbook-html/lib/totext.js index 13b1cd8..b1c94d4 100644 --- a/packages/gitbook-html/lib/totext.js +++ b/packages/gitbook-html/lib/totext.js @@ -123,6 +123,8 @@ ToText.prototype._summaryArticles = function(articles, level) { ToText.prototype._summaryPart = function(part) { var content = ''; + if (part.title) content += this.onTitleStart(2) + this.onText(part.title) + this.onTitleEnd(2); + content += this._summaryArticles(part.articles); content += this.onSection(); |