Skip to content

Commit f8dfa36

Browse files
committed
Merge branch 'master' of github.com:GitbookIO/gitbook
2 parents 66fc908 + dfd4876 commit f8dfa36

File tree

8 files changed

+21
-13
lines changed

8 files changed

+21
-13
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Release notes
22

3+
## 1.3.1
4+
- Fix error with links in markdown
5+
36
## 1.3.0
47
- Bundle gitbook parsing library as a client side library in `gitbook.js` and `gitbook.min.js`
58

lib/generate/json/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ Generator.prototype.convertFile = function(content, input) {
2929
dir: path.dirname(input) || '/'
3030
});
3131
})
32-
.then(function(sections) {
33-
json.sections = sections;
32+
.then(function(parsed) {
33+
json.lexed = parsed.lexed;
34+
json.sections = parsed.sections;
3435
})
3536
.then(function() {
3637
return fs.writeFile(

lib/generate/site/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Generator.prototype.prepareFile = function(content, _input) {
120120
.then(function() {
121121
// Lex, parse includes and get
122122
// Get HTML generated sections
123-
return parse.page(page, {
123+
return parse.page(page.content, {
124124
// Local files path
125125
dir: path.dirname(_input) || '/',
126126

@@ -134,8 +134,9 @@ Generator.prototype.prepareFile = function(content, _input) {
134134
], path.join, fs.readFileSync)
135135
});
136136
})
137-
.then(function(sections) {
138-
page.sections = sections;
137+
.then(function(parsed) {
138+
page.lexed = parsed.lexed;
139+
page.sections = parsed.sections;
139140

140141
// Use plugin hook
141142
return _callHook("page");

lib/parse/page.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ function quizQuestion(node) {
4747
}
4848
}
4949

50-
function parsePage(page, options) {
50+
function parsePage(src, options) {
5151
options = options || {};
5252

5353
// Lex if not already lexed
54-
page.lexed = (_.isArray(page.content) ? page.content : lex(include(page.content, options.includer || function() { return undefined; })))
55-
return page.lexed
56-
.map(function(section) {
54+
var parsed = {
55+
lexed: (_.isArray(src) ? page.content : lex(include(src, options.includer || function() { return undefined; })))
56+
};
57+
parsed.sections = parsed.lexed.map(function(section) {
5758
// Transform given type
5859
if(section.type === 'exercise') {
5960
var nonCodeNodes = _.reject(section, {
@@ -151,6 +152,8 @@ function parsePage(page, options) {
151152
content: render(section, options)
152153
};
153154
});
155+
156+
return parsed;
154157
}
155158

156159
// Exports

lib/parse/renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ GitBookRenderer.prototype.link = function(href, title, text) {
4949
// Parsed version of the url
5050
var parsed = url.parse(href);
5151
var o = this._extra_options;
52-
var extname = _.last(parsed.path.split("."));
52+
var extname = parsed.path? _.last(parsed.path.split(".")) : "";
5353

5454
// Relative link, rewrite it to point to github repo
5555
if(links.isRelative(_href) && extname == "md") {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gitbook",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"homepage": "http://www.gitbook.io/",
55
"description": "Library and cmd utility to generate GitBooks",
66
"main": "lib/index.js",

test/includes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var FIXTURES_DIR = path.join(__dirname, './fixtures/');
99

1010
function loadPage (name, options) {
1111
var CONTENT = fs.readFileSync(FIXTURES_DIR + name + '.md', 'utf8');
12-
return page(CONTENT, options);
12+
return page(CONTENT, options).sections;
1313
}
1414

1515

test/page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var page = require('../').parse.page;
66

77
function loadPage (name, options) {
88
var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/' + name + '.md'), 'utf8');
9-
return page(CONTENT, options);
9+
return page(CONTENT, options).sections;
1010
}
1111

1212
var LEXED = loadPage('PAGE', {

0 commit comments

Comments
 (0)