Compare commits

...

18 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
12 changed files with 123 additions and 31 deletions
+2
View File
@@ -55,3 +55,5 @@ Translators
- Hong Nguyen (@nghong)
- Hebrew
- @a-moses
- Ukrainian
- @Karnaukhov
+11
View File
@@ -2,6 +2,17 @@
All notable changes to this project will be documented in this file.
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 -1
View File
@@ -4,12 +4,13 @@ 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)
[![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).
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/).
+16 -2
View File
@@ -79,6 +79,8 @@ var Book = function(root, context, parent) {
this.langsFile = null;
// Search Index
this.searchIndexEnabled = true;
this.searchIndexSize = 0;
this.searchIndex = lunr(function () {
this.ref("url");
@@ -738,13 +740,25 @@ Book.prototype.contentLink = function(link) {
// Index a page into the search index
Book.prototype.indexPage = function(page) {
var nav = this.navigation[page.path];
if (!nav) return;
if (!nav || !this.searchIndexEnabled) return;
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({
url: this.contentLink(page.path),
title: nav.title,
body: pageUtil.extractText(page.sections),
body: text
});
};
+46 -15
View File
@@ -7,7 +7,21 @@ var pkg = require("../package.json");
var i18n = require("./utils/i18n");
// 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
function normalizePluginsList(plugins, addDefaults) {
@@ -22,9 +36,12 @@ function normalizePluginsList(plugins, addDefaults) {
if (plugin.name) return plugin;
var parts = plugin.split("@");
var name = parts[0];
var version = parts[1];
return {
"name": parts[0],
"version": parts[1] // optional
"name": name,
"version": version, // optional
"isDefault": isDefaultPlugin(name, version)
};
});
@@ -40,19 +57,26 @@ function normalizePluginsList(plugins, addDefaults) {
// Merge with defaults
if (addDefaults !== false) {
plugins = _.chain(plugins)
.concat(_.map(defaultsPlugins, function(plugin) {
return { "name": plugin };
}))
.uniq()
.value();
_.each(DEFAULT_PLUGINS, function(plugin) {
if (_.find(plugins, { name: plugin })) {
return;
}
plugins.push({
"name": plugin,
"isDefault": true
});
});
}
// Build final list
// Remove plugin that start with '-'
plugins = _.filter(plugins, function(plugin) {
return !_.contains(toremove, plugin.name) && !(plugin.name.length > 0 && plugin.name[0] == "-");
});
// Remove duplicates
plugins = _.uniq(plugins, 'name');
return plugins;
}
@@ -114,11 +138,13 @@ Configuration.prototype.load = function() {
}
})
.then(function() {
if (!semver.satisfies(pkg.version, that.options.gitbook)) {
throw "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.book.isSubBook()) {
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");
}
}
that.options.output = path.resolve(that.options.output || that.book.resolve("_book"));
@@ -175,6 +201,11 @@ Configuration.DEFAULT = {
// version of gitbook to use
"gitbook": "*",
// Search index
"search": {
"maxIndexSize": 1000000
},
// Structure
"structure": {
"langs": "LANGS.md",
+2 -3
View File
@@ -146,11 +146,10 @@ PluginsList.prototype.resources = function(namespace) {
// Install plugins from a book
PluginsList.prototype.install = function() {
var that = this;
var defaultsPlugins = _.pluck(that.book.options.defaultsPlugins);
// Remove defaults (no need to install)
var plugins = _.filter(that.book.options.plugins, function(plugin) {
return !_.contains(defaultsPlugins, plugin.name);
var plugins = _.reject(that.book.options.plugins, {
isDefault: true
});
// Install plugins one by one
+4 -3
View File
@@ -244,14 +244,15 @@ function normalizeHtml(src, options) {
.value();
var source = $(this).text();
var html = options.book.template.applyBlock("code", {
var blk = options.book.template.applyBlock("code", {
body: source,
kwargs: {
language: lang
}
}).body;
});
$(this).html(html);
if (blk.html === false) $(this).text(blk.body);
else $(this).html(blk.body);
});
// Replace glossary terms
+5 -5
View File
@@ -1,20 +1,20 @@
{
"name": "gitbook",
"version": "2.4.1",
"version": "2.4.3",
"homepage": "https://www.gitbook.com",
"description": "Library and cmd utility to generate GitBooks",
"main": "lib/index.js",
"dependencies": {
"q": "1.0.1",
"lunr": "0.5.7",
"lunr": "0.5.12",
"lodash": "3.10.1",
"graceful-fs": "3.0.5",
"resolve": "0.6.3",
"fs-extra": "0.16.5",
"fstream-ignore": "1.0.2",
"gitbook-parsers": "0.8.2",
"gitbook-plugin-highlight": "1.0.1",
"nunjucks": "mozilla/nunjucks#dc89bf91611a2101731c2c06afcf5c32160b4dc9",
"gitbook-parsers": "0.8.3",
"gitbook-plugin-highlight": "1.0.3",
"nunjucks": "2.1.0",
"nunjucks-autoescape": "1.0.0",
"nunjucks-filter": "1.0.0",
"i18n": "0.5.0",
+2 -1
View File
@@ -12,4 +12,5 @@ Block with a language
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"
}
});
});
});
+4 -1
View File
@@ -4,7 +4,10 @@ module.exports = {
process: function(blk) {
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"
}