diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/generate/index.js | 2 | ||||
-rw-r--r-- | lib/parse/navigation.js | 2 | ||||
-rw-r--r-- | lib/parse/summary.js | 16 |
3 files changed, 10 insertions, 10 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js index 8bb7052..6b75dea 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -238,7 +238,7 @@ var generateBook = function(options) { return loadGenerator(options); }) - // Detect multi-languages book + // Convert files .then(function(generator) { // Generate the book return Q() diff --git a/lib/parse/navigation.js b/lib/parse/navigation.js index 2f8669e..2c783e4 100644 --- a/lib/parse/navigation.js +++ b/lib/parse/navigation.js @@ -8,7 +8,7 @@ function clean(obj) { function flattenChapters(chapters) { return _.reduce(chapters, function(accu, chapter) { - return accu.concat([clean(chapter)].concat(chapter.articles)); + return accu.concat([clean(chapter)].concat(flattenChapters(chapter.articles))); }, []); } diff --git a/lib/parse/summary.js b/lib/parse/summary.js index af13088..1fd5676 100644 --- a/lib/parse/summary.js +++ b/lib/parse/summary.js @@ -86,13 +86,11 @@ function parseTitle(src, nums) { }; } -function parseArticle(chapterNum, nodes, idx) { - return parseTitle(_.first(nodes).text, [chapterNum, idx+1]); -} - -function parseChapter(nodes, idx) { - return _.extend(parseTitle(_.first(nodes).text, [idx+1]), { - articles: _.map(listSplit(filterList(nodes), 'list_item_start', 'list_item_end'), parseArticle.bind(null, idx+1)) +function parseChapter(nodes, nums) { + return _.extend(parseTitle(_.first(nodes).text, nums), { + articles: _.map(listSplit(filterList(nodes), 'list_item_start', 'list_item_end'), function(nodes, i) { + return parseChapter(nodes, nums.concat(i + 1)); + }) }); } @@ -104,7 +102,9 @@ function parseSummary(src) { // Split out chapter sections var chapters = _.chain(listSplit(chapterList, 'list_item_start', 'list_item_end')) - .map(parseChapter) + .map(function(nodes, i) { + return parseChapter(nodes, [i + 1]); + }) .value(); return { |