gitbook-markdown
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -95,21 +95,2 @@ var _ = require('lodash'); | ||
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) { | ||
@@ -125,7 +106,5 @@ var nodes = kramed.lexer(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); | ||
@@ -132,0 +111,0 @@ |
{ | ||
"name": "gitbook-markdown", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"homepage": "https://www.gitbook.com", | ||
@@ -5,0 +5,0 @@ "description": "Parse markdown content for gitbook", |
@@ -12,9 +12,9 @@ var fs = require('fs'); | ||
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); | ||
}); | ||
@@ -27,4 +27,3 @@ | ||
assert(LEXED.chapters[3].path); | ||
assert(LEXED.chapters[4].path); | ||
assert.equal(LEXED.chapters[5].path, null); | ||
assert.equal(LEXED.chapters[4].path, null); | ||
@@ -36,11 +35,9 @@ assert(LEXED.chapters[0].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'); | ||
}); | ||
}); |
14055
345