diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-24 11:34:33 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-12-22 15:00:32 +0100 |
commit | e2ca57ef31e64566ce3066fba9f3001e0612c2f2 (patch) | |
tree | a9e6be1f5727ffa57ec5bbf098cff613c8f4619c | |
parent | 1c471da01a04b1668d8401c833d054e7ed50ca74 (diff) | |
download | gitbook-e2ca57ef31e64566ce3066fba9f3001e0612c2f2.zip gitbook-e2ca57ef31e64566ce3066fba9f3001e0612c2f2.tar.gz gitbook-e2ca57ef31e64566ce3066fba9f3001e0612c2f2.tar.bz2 |
Don't add entry point in summary
-rw-r--r-- | packages/gitbook-markdown/lib/summary.js | 25 | ||||
-rw-r--r-- | packages/gitbook-markdown/test/summary.js | 17 |
2 files changed, 9 insertions, 33 deletions
diff --git a/packages/gitbook-markdown/lib/summary.js b/packages/gitbook-markdown/lib/summary.js index 9b5c577..3953cb8 100644 --- a/packages/gitbook-markdown/lib/summary.js +++ b/packages/gitbook-markdown/lib/summary.js @@ -92,25 +92,6 @@ function parseChapter(nodes) { }); } -function defaultChapterList(chapterList, entryPoint) { - var first = _.first(chapterList); - - // Check if introduction node was specified in SUMMARY.md - if (first) { - var chapter = parseChapter(first, [0]); - - // Already have README node, we're good to go - if(chapter.path === entryPoint) { - return chapterList; - } - } - - // It wasn't specified, so add in default - return [ - [ { type: 'text', text: '[Introduction]('+entryPoint+')' } ] - ].concat(chapterList); -} - function listGroups(src) { var nodes = kramed.lexer(src); @@ -121,11 +102,9 @@ function listGroups(src) { ); } -function parseSummary(src, entryPoint) { - entryPoint = entryPoint || "README.md"; - +function parseSummary(src) { // Split out chapter sections - var chapters = defaultChapterList(listGroups(src), entryPoint) + var chapters = listGroups(src) .map(parseChapter); return { diff --git a/packages/gitbook-markdown/test/summary.js b/packages/gitbook-markdown/test/summary.js index a79f534..2794f27 100644 --- a/packages/gitbook-markdown/test/summary.js +++ b/packages/gitbook-markdown/test/summary.js @@ -9,13 +9,13 @@ var LEXED = summary(CONTENT); describe('Summary parsing', function () { it('should detect chapters', function() { - assert.equal(LEXED.chapters.length, 6); + assert.equal(LEXED.chapters.length, 5); }); it('should support articles', function() { - assert.equal(LEXED.chapters[1].articles.length, 2); + assert.equal(LEXED.chapters[0].articles.length, 2); + assert.equal(LEXED.chapters[1].articles.length, 0); assert.equal(LEXED.chapters[2].articles.length, 0); - assert.equal(LEXED.chapters[3].articles.length, 0); }); it('should detect paths and titles', function() { @@ -23,21 +23,18 @@ describe('Summary parsing', function () { assert(LEXED.chapters[1].path); assert(LEXED.chapters[2].path); assert(LEXED.chapters[3].path); - assert(LEXED.chapters[4].path); - assert.equal(LEXED.chapters[5].path, null); + assert.equal(LEXED.chapters[4].path, null); assert(LEXED.chapters[0].title); assert(LEXED.chapters[1].title); assert(LEXED.chapters[2].title); assert(LEXED.chapters[3].title); assert(LEXED.chapters[4].title); - assert(LEXED.chapters[5].title); }); it('should normalize paths from .md', function() { - assert.equal(LEXED.chapters[0].path,'README.md'); - assert.equal(LEXED.chapters[1].path,'chapter-1/README.md'); - assert.equal(LEXED.chapters[2].path,'chapter-2/README.md'); - assert.equal(LEXED.chapters[3].path,'chapter-3/README.md'); + assert.equal(LEXED.chapters[0].path,'chapter-1/README.md'); + assert.equal(LEXED.chapters[1].path,'chapter-2/README.md'); + assert.equal(LEXED.chapters[2].path,'chapter-3/README.md'); }); }); |