mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-28 04:58:52 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07d5245a5f | |||
| 6b844213ec | |||
| dabdeb8a80 | |||
| ecd56315e6 | |||
| 15b9e839e9 | |||
| d7f7dcd47b | |||
| b1981e09b8 | |||
| c9edd0a795 | |||
| d83e0716bb |
+1
-1
@@ -25,7 +25,7 @@ Each chapter has a dedicated page (`part#/README.md`) and is split into subchapt
|
||||
|
||||
##### Anchors
|
||||
|
||||
Chaptersi n the Table of Contents can be pointing to specific part of a file using anchor.
|
||||
Chapters in the Table of Contents can be pointing to specific part of a file using anchor.
|
||||
|
||||
```markdown
|
||||
# Summary
|
||||
|
||||
+6
-4
@@ -38,10 +38,8 @@ function Output(book, opts, parent) {
|
||||
// Files to ignore in output
|
||||
this.ignore = Ignore();
|
||||
|
||||
// Hack to inherits from rules of the book:
|
||||
// Waiting for https://github.com/kaelzhang/node-ignore/pull/19 to be merged
|
||||
this.ignore._rules = this.ignore._rules.concat(this.book.ignore._rules);
|
||||
this.ignore._cache = {};
|
||||
// Hack to inherits from rules of the book
|
||||
this.ignore.add(this.book.ignore);
|
||||
}
|
||||
|
||||
// Default name for generator
|
||||
@@ -209,6 +207,10 @@ Output.prototype.onOutputSVG = function(page, svg) {
|
||||
// Output an image as a file
|
||||
// Normalize the relative link
|
||||
Output.prototype.onOutputImage = function(page, imgFile) {
|
||||
if (location.isExternal(imgFile)) {
|
||||
return imgFile;
|
||||
}
|
||||
|
||||
imgFile = page.resolveLocal(imgFile);
|
||||
return page.relative(imgFile);
|
||||
};
|
||||
|
||||
@@ -144,10 +144,15 @@ function listInstalled(folder) {
|
||||
function listPlugins(book) {
|
||||
return Promise.all([
|
||||
listInstalled(path.resolve(__dirname, '../..')),
|
||||
listInstalled(book.root)
|
||||
listInstalled(book.root),
|
||||
book.isLanguageBook()? listInstalled(book.parent.root) : Promise([])
|
||||
])
|
||||
.spread(function(defaultPlugins, plugins) {
|
||||
var results = plugins.concat(defaultPlugins);
|
||||
var args = _.toArray(arguments);
|
||||
var results = _.reduce(args, function(out, a) {
|
||||
return out.concat(a);
|
||||
}, []);
|
||||
|
||||
return _.uniq(results, 'name');
|
||||
});
|
||||
}
|
||||
|
||||
+10
-6
@@ -63,6 +63,13 @@ function TemplateEngine(output) {
|
||||
// Add default blocks and filters
|
||||
this.addBlocks(defaultBlocks);
|
||||
this.addFilters(defaultFilters);
|
||||
|
||||
// Build context for this book with depreacted fields
|
||||
this.ctx = {
|
||||
book: this.book,
|
||||
output: this.output
|
||||
};
|
||||
error.deprecateField(this.ctx, 'generator', this.output.name, '"generator" property is deprecated, use "output.generator" instead');
|
||||
}
|
||||
|
||||
// Bind a function to a context
|
||||
@@ -71,12 +78,9 @@ TemplateEngine.prototype.bindContext = function(func) {
|
||||
var that = this;
|
||||
|
||||
return function() {
|
||||
var ctx = {
|
||||
ctx: this.ctx,
|
||||
book: that.book,
|
||||
output: that.output
|
||||
};
|
||||
error.deprecateField(ctx, 'generator', that.output.name, '"generator" property is deprecated, use "output.generator" instead');
|
||||
var ctx = _.extend({
|
||||
ctx: this.ctx
|
||||
}, that.ctx);
|
||||
|
||||
return func.apply(ctx, arguments);
|
||||
};
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "3.0.0-pre.6",
|
||||
"version": "3.0.0-pre.7",
|
||||
"homepage": "https://www.gitbook.com",
|
||||
"description": "Library and cmd utility to generate GitBooks",
|
||||
"main": "lib/index.js",
|
||||
@@ -26,11 +26,11 @@
|
||||
"gitbook-plugin-livereload": "0.0.1",
|
||||
"gitbook-plugin-search": "1.2.0",
|
||||
"gitbook-plugin-sharing": "1.0.1",
|
||||
"gitbook-plugin-theme-default": "1.0.0-pre.5",
|
||||
"gitbook-plugin-theme-default": "1.0.0-pre.6",
|
||||
"github-slugid": "1.0.1",
|
||||
"graceful-fs": "4.1.3",
|
||||
"i18n-t": "1.0.0",
|
||||
"ignore": "3.0.14",
|
||||
"ignore": "3.1.1",
|
||||
"json-schema-defaults": "0.1.1",
|
||||
"jsonschema": "1.1.0",
|
||||
"juice": "1.10.0",
|
||||
|
||||
+2
-1
@@ -53,9 +53,10 @@ describe('JSON Output', function() {
|
||||
|
||||
it('should correctly generate a README.json for the whole book', function() {
|
||||
output.should.have.file('README.json');
|
||||
|
||||
var json = require(output.resolve('README.json'));
|
||||
|
||||
json.book.language.should.equal('en');
|
||||
|
||||
json.should.have.property('languages')
|
||||
.with.property('list').with.lengthOf(2);
|
||||
});
|
||||
|
||||
+1
-1
@@ -289,7 +289,7 @@ describe('Page', function() {
|
||||
|
||||
it('should keep external images path', function() {
|
||||
page.content.should.be.html({
|
||||
'img[src="https:/upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"]': {
|
||||
'img[src="https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"]': {
|
||||
count: 1
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user