Compare commits

...

21 Commits

Author SHA1 Message Date
Samy Pessé f0c97756de Bump version to 2.4.3 2015-10-01 14:07:32 +02:00
Samy Pessé f14c57d4c2 Merge pull request #955 from mstade/patch-1
Change nunjucks dependency to v2.1.0
2015-10-01 12:03:21 +02:00
Marcus Stade b6f60cc8ad Change nunjucks dependency to v2.1.0
Looks like mozilla/nunjucks#504 was merged and released in v2.1.0, so this changes `package.json` to no longer depend on a specific commit. Incidentally, this also solves a problem where corporate firewalls blocks npm from pulling in straight from github repos.
2015-10-01 12:01:52 +02:00
Samy Pessé 170516d343 Add ukranian translation 2015-09-28 21:01:28 +02:00
Samy Pessé c931e91bef Fix #952: add configuration for index maximum size 2015-09-28 20:54:45 +02:00
Samy Pessé db9151ae36 Update gitbook-parsers@0.8.3 2015-09-28 20:40:02 +02:00
Samy Pessé f2d86b6d69 Add slack button in readme 2015-09-23 12:19:04 +02:00
Samy Pessé 534cdd091b Add link to slack community channel 2015-09-23 12:16:22 +02:00
Samy Pessé fdf4a48638 Bump version to 2.4.2 2015-09-22 23:30:42 +02:00
Samy Pessé 58a3c5634e Improve installation of plugins to not install default ones 2015-09-22 23:25:15 +02:00
Samy Pessé f0ddb6e89f Merge branch 'fix/inline_code_html' 2015-09-22 22:46:19 +02:00
Samy Pessé 2b408db7cb Update gitbook-plugin-highlight@1.0.3 2015-09-22 22:45:55 +02:00
Samy Pessé 4e4bd23e2b Handle html param from code block output 2015-09-22 22:41:13 +02:00
Samy Pessé 62d0eb606e Add test for inline code block with html tags 2015-09-22 22:36:35 +02:00
Samy Pessé 0e9beeae14 Fix #941: limit size of lunr index 2015-09-22 12:36:18 +02:00
Samy Pessé 5e4dbdee24 Disable auto code highlighting (language should be specified) 2015-09-21 16:19:42 +02:00
Samy Pessé 9435dae6cd Fix #939: don't check gitbook version for sub-books (checked for parent) 2015-09-21 09:41:29 +02:00
Samy Pessé 813210bf47 Throw correct error in configuration 2015-09-20 23:27:39 +02:00
Samy Pessé c372dfc544 Bump version to 2.4.1 2015-09-19 00:32:43 +02:00
Samy Pessé ac77200683 Fix disabling a default plugin 2015-09-19 00:31:32 +02:00
Samy Pessé f5afbc90a4 Add more tests for blocks args/kwargs 2015-09-17 11:21:55 +02:00
13 changed files with 145 additions and 34 deletions
+2
View File
@@ -55,3 +55,5 @@ Translators
- Hong Nguyen (@nghong) - Hong Nguyen (@nghong)
- Hebrew - Hebrew
- @a-moses - @a-moses
- Ukrainian
- @Karnaukhov
+14
View File
@@ -2,6 +2,20 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/). This project adheres to [Semantic Versioning](http://semver.org/).
## 2.4.3
- Add ukrainian translation (`uk`)
- Add `book.json` configuration for maximum size of search index
- Improve reliability of summary parser
## 2.4.2
- Default plugins should not be installed by `gitbook install`
- Limit search index size to avoid crash during generation
- Fix code highlighting for html without language specified
- Fix warning message for gitbook version when building a multilingual book
## 2.4.1
- Fix disabling of default plugins, ex: `-highlight`
## 2.4.0 ## 2.4.0
- Fix page being updated when user wants to open a link in a new tab - Fix page being updated when user wants to open a link in a new tab
- Plugins can now replaced default code highlighter - Plugins can now replaced default code highlighter
+2 -1
View File
@@ -4,12 +4,13 @@ GitBook
[![NPM version](https://badge.fury.io/js/gitbook.svg)](http://badge.fury.io/js/gitbook) [![NPM version](https://badge.fury.io/js/gitbook.svg)](http://badge.fury.io/js/gitbook)
[![Linux Build Status](https://travis-ci.org/GitbookIO/gitbook.png?branch=master)](https://travis-ci.org/GitbookIO/gitbook) [![Linux Build Status](https://travis-ci.org/GitbookIO/gitbook.png?branch=master)](https://travis-ci.org/GitbookIO/gitbook)
[![Windows Build status](https://ci.appveyor.com/api/projects/status/63nlflxcwmb2pue6?svg=true)](https://ci.appveyor.com/project/GitBook/gitbook) [![Windows Build status](https://ci.appveyor.com/api/projects/status/63nlflxcwmb2pue6?svg=true)](https://ci.appveyor.com/project/GitBook/gitbook)
[![Slack Status](https://slack.gitbook.com/badge.svg)](https://slack.gitbook.com)
GitBook is a command line tool (and Node.js library) for building beautiful books using GitHub/Git and Markdown (or AsciiDoc). Here is an example: [Learn Javascript](https://www.gitbook.com/book/GitBookIO/javascript). GitBook is a command line tool (and Node.js library) for building beautiful books using GitHub/Git and Markdown (or AsciiDoc). Here is an example: [Learn Javascript](https://www.gitbook.com/book/GitBookIO/javascript).
You can publish and host book easily online using [gitbook.com](https://www.gitbook.com), a desktop editor is [also available](https://www.gitbook.com/editor). You can publish and host book easily online using [gitbook.com](https://www.gitbook.com), a desktop editor is [also available](https://www.gitbook.com/editor).
Stay updated by following [@GitBookIO](https://twitter.com/GitBookIO) on Twitter or [GitBook](https://www.facebook.com/gitbookcom) on Facebook. Check out the [GitBook Community Slack Channel](https://slack.gitbook.com), Stay updated by following [@GitBookIO](https://twitter.com/GitBookIO) on Twitter or [GitBook](https://www.facebook.com/gitbookcom) on Facebook.
Complete documentation is available at [help.gitbook.com](http://help.gitbook.com/). Complete documentation is available at [help.gitbook.com](http://help.gitbook.com/).
+16 -2
View File
@@ -79,6 +79,8 @@ var Book = function(root, context, parent) {
this.langsFile = null; this.langsFile = null;
// Search Index // Search Index
this.searchIndexEnabled = true;
this.searchIndexSize = 0;
this.searchIndex = lunr(function () { this.searchIndex = lunr(function () {
this.ref("url"); this.ref("url");
@@ -738,13 +740,25 @@ Book.prototype.contentLink = function(link) {
// Index a page into the search index // Index a page into the search index
Book.prototype.indexPage = function(page) { Book.prototype.indexPage = function(page) {
var nav = this.navigation[page.path]; var nav = this.navigation[page.path];
if (!nav) return; if (!nav || !this.searchIndexEnabled) return;
this.log.debug.ln("index page", page.path); this.log.debug.ln("index page", page.path);
// Extract text from the page
var text = pageUtil.extractText(page.sections);
// Limit size of index (to avoid #941)
this.searchIndexSize = this.searchIndexSize + text.length;
if (this.searchIndexSize > this.config.get('search.maxIndexSize')) {
this.log.warn.ln("search index is too big, indexing is now disabled");
this.searchIndexEnabled = false;
return;
}
this.searchIndex.add({ this.searchIndex.add({
url: this.contentLink(page.path), url: this.contentLink(page.path),
title: nav.title, title: nav.title,
body: pageUtil.extractText(page.sections), body: text
}); });
}; };
+50 -17
View File
@@ -7,10 +7,24 @@ var pkg = require("../package.json");
var i18n = require("./utils/i18n"); var i18n = require("./utils/i18n");
// Default plugins added to each books // Default plugins added to each books
var defaultsPlugins = ["highlight"]; var DEFAULT_PLUGINS = ["highlight"];
// Check if a plugin is a default plugin
// Plugin should be in the list
// And version from book.json specified for this plugin should be satisfied
function isDefaultPlugin(name, version) {
if (!_.contains(DEFAULT_PLUGINS, name)) return false;
try {
var pluginPkg = require('gitbook-plugin-'+name+'/package.json');
return semver.satisfies(pluginPkg.version, version || '*');
} catch(e) {
return false;
}
}
// Normalize a list of plugins to use // Normalize a list of plugins to use
function normalizePluginsList(plugins) { function normalizePluginsList(plugins, addDefaults) {
// Normalize list to an array // Normalize list to an array
plugins = _.isString(plugins) ? plugins.split(",") : (plugins || []); plugins = _.isString(plugins) ? plugins.split(",") : (plugins || []);
@@ -22,9 +36,12 @@ function normalizePluginsList(plugins) {
if (plugin.name) return plugin; if (plugin.name) return plugin;
var parts = plugin.split("@"); var parts = plugin.split("@");
var name = parts[0];
var version = parts[1];
return { return {
"name": parts[0], "name": name,
"version": parts[1] // optional "version": version, // optional
"isDefault": isDefaultPlugin(name, version)
}; };
}); });
@@ -39,18 +56,27 @@ function normalizePluginsList(plugins) {
.value(); .value();
// Merge with defaults // Merge with defaults
plugins = _.chain(plugins) if (addDefaults !== false) {
.concat(_.map(defaultsPlugins, function(plugin) { _.each(DEFAULT_PLUGINS, function(plugin) {
return { "name": plugin }; if (_.find(plugins, { name: plugin })) {
})) return;
.uniq() }
.value();
// Build final list plugins.push({
"name": plugin,
"isDefault": true
});
});
}
// Remove plugin that start with '-'
plugins = _.filter(plugins, function(plugin) { plugins = _.filter(plugins, function(plugin) {
return !_.contains(toremove, plugin.name) && !(plugin.name.length > 0 && plugin.name[0] == "-"); return !_.contains(toremove, plugin.name) && !(plugin.name.length > 0 && plugin.name[0] == "-");
}); });
// Remove duplicates
plugins = _.uniq(plugins, 'name');
return plugins; return plugins;
} }
@@ -112,16 +138,18 @@ Configuration.prototype.load = function() {
} }
}) })
.then(function() { .then(function() {
if (!semver.satisfies(pkg.version, that.options.gitbook)) { if (!that.book.isSubBook()) {
throw "GitBook version doesn't satisfy version required by the book: "+that.options.gitbook; if (!semver.satisfies(pkg.version, that.options.gitbook)) {
} throw new Error("GitBook version doesn't satisfy version required by the book: "+that.options.gitbook);
if (that.options.gitbook != "*" && !semver.satisfies(semver.inc(pkg.version, "patch"), that.options.gitbook)) { }
that.book.log.warn.ln("gitbook version specified in your book.json might be too strict for future patches, \""+(_.first(pkg.version.split("."))+".x.x")+"\" is more adequate"); if (that.options.gitbook != "*" && !semver.satisfies(semver.inc(pkg.version, "patch"), that.options.gitbook)) {
that.book.log.warn.ln("gitbook version specified in your book.json might be too strict for future patches, \""+(_.first(pkg.version.split("."))+".x.x")+"\" is more adequate");
}
} }
that.options.output = path.resolve(that.options.output || that.book.resolve("_book")); that.options.output = path.resolve(that.options.output || that.book.resolve("_book"));
that.options.plugins = normalizePluginsList(that.options.plugins); that.options.plugins = normalizePluginsList(that.options.plugins);
that.options.defaultsPlugins = normalizePluginsList(that.options.defaultsPlugins || ""); that.options.defaultsPlugins = normalizePluginsList(that.options.defaultsPlugins || "", false);
that.options.plugins = _.union(that.options.plugins, that.options.defaultsPlugins); that.options.plugins = _.union(that.options.plugins, that.options.defaultsPlugins);
that.options.plugins = _.uniq(that.options.plugins, "name"); that.options.plugins = _.uniq(that.options.plugins, "name");
@@ -173,6 +201,11 @@ Configuration.DEFAULT = {
// version of gitbook to use // version of gitbook to use
"gitbook": "*", "gitbook": "*",
// Search index
"search": {
"maxIndexSize": 1000000
},
// Structure // Structure
"structure": { "structure": {
"langs": "LANGS.md", "langs": "LANGS.md",
+2 -3
View File
@@ -146,11 +146,10 @@ PluginsList.prototype.resources = function(namespace) {
// Install plugins from a book // Install plugins from a book
PluginsList.prototype.install = function() { PluginsList.prototype.install = function() {
var that = this; var that = this;
var defaultsPlugins = _.pluck(that.book.options.defaultsPlugins);
// Remove defaults (no need to install) // Remove defaults (no need to install)
var plugins = _.filter(that.book.options.plugins, function(plugin) { var plugins = _.reject(that.book.options.plugins, {
return !_.contains(defaultsPlugins, plugin.name); isDefault: true
}); });
// Install plugins one by one // Install plugins one by one
+4 -3
View File
@@ -244,14 +244,15 @@ function normalizeHtml(src, options) {
.value(); .value();
var source = $(this).text(); var source = $(this).text();
var html = options.book.template.applyBlock("code", { var blk = options.book.template.applyBlock("code", {
body: source, body: source,
kwargs: { kwargs: {
language: lang language: lang
} }
}).body; });
$(this).html(html); if (blk.html === false) $(this).text(blk.body);
else $(this).html(blk.body);
}); });
// Replace glossary terms // Replace glossary terms
+5 -5
View File
@@ -1,20 +1,20 @@
{ {
"name": "gitbook", "name": "gitbook",
"version": "2.4.0", "version": "2.4.3",
"homepage": "https://www.gitbook.com", "homepage": "https://www.gitbook.com",
"description": "Library and cmd utility to generate GitBooks", "description": "Library and cmd utility to generate GitBooks",
"main": "lib/index.js", "main": "lib/index.js",
"dependencies": { "dependencies": {
"q": "1.0.1", "q": "1.0.1",
"lunr": "0.5.7", "lunr": "0.5.12",
"lodash": "3.10.1", "lodash": "3.10.1",
"graceful-fs": "3.0.5", "graceful-fs": "3.0.5",
"resolve": "0.6.3", "resolve": "0.6.3",
"fs-extra": "0.16.5", "fs-extra": "0.16.5",
"fstream-ignore": "1.0.2", "fstream-ignore": "1.0.2",
"gitbook-parsers": "0.8.2", "gitbook-parsers": "0.8.3",
"gitbook-plugin-highlight": "1.0.1", "gitbook-plugin-highlight": "1.0.3",
"nunjucks": "mozilla/nunjucks#dc89bf91611a2101731c2c06afcf5c32160b4dc9", "nunjucks": "2.1.0",
"nunjucks-autoescape": "1.0.0", "nunjucks-autoescape": "1.0.0",
"nunjucks-filter": "1.0.0", "nunjucks-filter": "1.0.0",
"i18n": "0.5.0", "i18n": "0.5.0",
+2 -1
View File
@@ -12,4 +12,5 @@ Block with a language
test 2 test 2
``` ```
Inline code: `test 3` Inline code: `test 3`
Inline code with html: `<test>`
+9
View File
@@ -52,5 +52,14 @@ describe("Code Highlighting", function () {
} }
}); });
}); });
it("should correctly replace highlighting for inline code with html tags", function() {
PAGE.should.be.html({
"code": {
index: 3,
text: "code_<test>_code"
}
});
});
}); });
+15 -1
View File
@@ -192,7 +192,21 @@ describe("Plugins", function () {
}); });
}); });
it("should correctly extend template blocks with arguments", function() { it("should correctly extend template blocks with arguments (1)", function() {
return testTpl("{% test5args \"a\" %}{% endtest5args %}")
.then(function(content) {
content.should.equal("test5atest5");
});
});
it("should correctly extend template blocks with arguments (2)", function() {
return testTpl("{% test5args 'a', 'b' %}{% endtest5args %}")
.then(function(content) {
content.should.equal("test5a,btest5");
});
});
it("should correctly extend template blocks with arguments (3)", function() {
return testTpl("{% test5args 'a', 'b', 'c' %}{% endtest5args %}") return testTpl("{% test5args 'a', 'b', 'c' %}{% endtest5args %}")
.then(function(content) { .then(function(content) {
content.should.equal("test5a,b,ctest5"); content.should.equal("test5a,b,ctest5");
+4 -1
View File
@@ -4,7 +4,10 @@ module.exports = {
process: function(blk) { process: function(blk) {
var lang = blk.kwargs.language || "code"; var lang = blk.kwargs.language || "code";
return lang+"_"+blk.body+"_"+lang; return {
body: lang+"_"+blk.body+"_"+lang,
html: false
};
} }
} }
} }
+20
View File
@@ -0,0 +1,20 @@
{
"LANGS_CHOOSE": "Виберіть мову",
"GLOSSARY": "Глосарій",
"GLOSSARY_INDEX": "Глосарій",
"GLOSSARY_OPEN": "Глосарій",
"GITBOOK_LINK": "Опубліковано за допомогою GitBook",
"SUMMARY": "Зміст",
"SUMMARY_INTRODUCTION": "Вступ",
"SUMMARY_TOGGLE": "Зміст",
"SEARCH_TOGGLE": "Пошук",
"SEARCH_PLACEHOLDER": "Введіть для пошуку",
"FONTSETTINGS_TOGGLE": "Шрифт",
"SHARE_TOGGLE": "Поділиться",
"SHARE_ON": "Поділитися в {{platform}}",
"FONTSETTINGS_WHITE": "Світлий",
"FONTSETTINGS_SEPIA": "Сепія",
"FONTSETTINGS_NIGHT": "Темний",
"FONTSETTINGS_SANS": "Sans",
"FONTSETTINGS_SERIF": "Serif"
}