mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-26 12:18:01 +00:00
Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3218ee7455 | |||
| 0552007b8a | |||
| 50bc89d9d9 | |||
| 743a88f53a | |||
| ee92c6dd99 | |||
| b6c54c17d1 | |||
| 992ef1ab74 | |||
| 960848ba34 | |||
| d9aca7a9df | |||
| 05a0de2d86 | |||
| 19e4f498cf | |||
| 3055139297 | |||
| 3d6b099dea | |||
| dd970e33b8 | |||
| 59ba479465 | |||
| 54c9ecf3c2 | |||
| 8308ae69a2 | |||
| bd6c3287ed | |||
| 24fc36deb1 | |||
| 2f44b61cec | |||
| 45ee503db1 | |||
| dc826da99b | |||
| 3ea659d582 | |||
| 34fc2831e0 | |||
| 1bf68a5aa0 | |||
| d72c397f23 | |||
| 2c69525148 | |||
| ee3a0ba801 | |||
| 7a4179a2a2 | |||
| 1d0083c5f4 | |||
| 33a6111a30 | |||
| a5d7a87e31 | |||
| c7f7c5b5ab | |||
| 55a7b99b4d | |||
| 8bfba604b3 | |||
| 2a5fa1c5fb | |||
| a3e95feb26 | |||
| 145b00f590 | |||
| 5f2785f0a8 | |||
| 412529c548 | |||
| 547ec6ade8 | |||
| eac513cfa3 | |||
| 5ec8a1f18c | |||
| c923a7e01a | |||
| e1594cde2c |
@@ -28,6 +28,8 @@ Translators
|
||||
- Andrey Akinshin (@AndreyAkinshin)
|
||||
- Norwegian
|
||||
- Knut Melvær (@kmelve)
|
||||
- Persian (Farsi)
|
||||
- Mohammad Hossein Mojtahedi (@mhm5000)
|
||||
- Portuguese
|
||||
- Ryan O'Mullan (@RyanOM)
|
||||
- Spanish
|
||||
|
||||
+12
@@ -2,6 +2,18 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## 2.0.0-beta.2
|
||||
- Fix definition of entry point title using SUMMARY.md
|
||||
|
||||
## 2.0.0-beta.1
|
||||
- Fix windows incompatibility
|
||||
- Add support for rtl (enabled by default for `ar` and `fa`)
|
||||
- Escape code blocks in markdown parser
|
||||
- Add Persian/Farsi translation (`fa`)
|
||||
- Add Arabic translation (`ar`)
|
||||
- Add Bengali translation (`bn`)
|
||||
- Provide generator name in template context
|
||||
|
||||
## 2.0.0-alpha.9
|
||||
- Fix links in sidebar
|
||||
- Fix normalization of html link (README to index)
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
GitBook
|
||||
=======
|
||||
|
||||
:warning: This branch contains the version 2.0.
|
||||
|
||||
[](https://travis-ci.org/GitbookIO/gitbook)
|
||||
[](http://badge.fury.io/js/gitbook)
|
||||
[](https://travis-ci.org/GitbookIO/gitbook)
|
||||
[](https://ci.appveyor.com/project/SamyPesse/gitbook)
|
||||
|
||||
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 web-editor is [also available](https://www.gitbook.com/editor). You can follow [@GitBookIO](https://twitter.com/GitBookIO) on Twitter. Complete documentation is available at [help.gitbook.io](http://help.gitbook.io/).
|
||||
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 web-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.
|
||||
|
||||
Complete documentation is available at [help.gitbook.com](http://help.gitbook.com/).
|
||||
|
||||

|
||||
|
||||
@@ -38,14 +43,14 @@ $ gitbook build ./repository ./outputFolder
|
||||
|
||||
## Features
|
||||
|
||||
* [Output as a website or ebook (pdf, epub, mobi)](#output-formats)
|
||||
* [Multi-Languages](#multi-languages)
|
||||
* [Glossary](#glossary)
|
||||
* [Cover](#cover)
|
||||
* [AsciiDoc Support](#asciidoc)
|
||||
* [Variables and Templating](#variables-and-templating)
|
||||
* [Content References](#content-references)
|
||||
* [Plugins](#plugins)
|
||||
* [Output as a website or ebook (pdf, epub, mobi)](http://help.gitbook.com/format/output.html)
|
||||
* [Multi-Languages](http://help.gitbook.com/format/languages.html)
|
||||
* [Glossary](http://help.gitbook.com/format/glossary.html)
|
||||
* [Cover](http://help.gitbook.com/format/cover.html)
|
||||
* [AsciiDoc Support](http://help.gitbook.com/format/asciidoc.html)
|
||||
* [Variables and Templating](http://help.gitbook.com/format/templating.html)
|
||||
* [Content References](http://help.gitbook.com/format/conrefs.html)
|
||||
* [Plugins](http://help.gitbook.com/plugins/index.html)
|
||||
* Interractive reader website:
|
||||
* Search
|
||||
* Font Settings (Serif, Sans Serif)
|
||||
@@ -199,7 +204,7 @@ The platform [GitBook.com](https://www.gitbook.com/) is like an "Heroku for book
|
||||
|
||||
Plugins can be used to extend your book's functionality. Read [GitbookIO/plugin](https://github.com/GitbookIO/plugin) for more information about how to build a plugin for GitBook.
|
||||
|
||||
Plugins needed to build a book can be installed using: `gitbook install ./`. You can find plugins at [plugins.gitbook.com](plugins.gitbook.com).
|
||||
Plugins needed to build a book can be installed using: `gitbook install ./`. You can find plugins at [plugins.gitbook.com](http://plugins.gitbook.com).
|
||||
|
||||
|
||||
## Debugging
|
||||
@@ -209,3 +214,16 @@ You can use the options `--log=debug` and `--debug` to get better error messages
|
||||
```
|
||||
$ gitbook build ./ -- log=debug --debug
|
||||
```
|
||||
|
||||
#### How to use the latest commit from GitBook in gitbook-cli
|
||||
|
||||
To use the latest commit from `GitBook/gitbook` with `gitbook-cli`:
|
||||
|
||||
```
|
||||
$ git clone https://github.com/GitbookIO/gitbook.git ./gitbook
|
||||
$ gitbook versions:link 2.0.0 ./gitbook
|
||||
```
|
||||
|
||||
Now the version tag `2.0.0` wil be associated with the `./gitbook` folder.
|
||||
|
||||
You can uninstall it using: `gitbook versions:uninstall 2.0.0`.
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# Fix line endings in Windows. (runs before repo cloning)
|
||||
init:
|
||||
- git config --global core.autocrlf input
|
||||
|
||||
# Test against these versions of Node.js.
|
||||
environment:
|
||||
matrix:
|
||||
- nodejs_version: "0.10"
|
||||
- nodejs_version: "0.11"
|
||||
|
||||
# Install scripts. (runs after repo cloning)
|
||||
install:
|
||||
# Get the latest stable version of Node.js or io.js
|
||||
- ps: Install-Product node $env:nodejs_version
|
||||
# install svgexport
|
||||
- npm install svgexport -g
|
||||
# install modules
|
||||
- npm install
|
||||
|
||||
# Post-install test scripts.
|
||||
test_script:
|
||||
# Output useful info for debugging.
|
||||
- node --version
|
||||
- npm --version
|
||||
# run tests
|
||||
- npm test
|
||||
|
||||
# Don't actually build.
|
||||
build: off
|
||||
+1
-1
@@ -3,5 +3,5 @@
|
||||
var color = require('bash-color');
|
||||
|
||||
console.log(color.red("You need to install 'gitbook-cli' to have access to the gitbook command anywhere on your system."));
|
||||
console.log(color.red("If you've installe this package globally, you need to uninstall it."));
|
||||
console.log(color.red("If you've installed this package globally, you need to uninstall it."));
|
||||
console.log(color.red(">> Run 'npm uninstall -g gitbook' then 'npm install -g gitbook-cli'"));
|
||||
|
||||
+10
-1
@@ -420,6 +420,7 @@ Book.prototype.parseSummary = function() {
|
||||
.then(function(content) {
|
||||
return summary.parser.summary(content, {
|
||||
entryPoint: that.readmeFile,
|
||||
entryPointTitle: "",
|
||||
files: that.files
|
||||
});
|
||||
});
|
||||
@@ -507,12 +508,20 @@ Book.prototype.parsePage = function(filename, options) {
|
||||
return interpolate(options.interpolateTemplate);
|
||||
})
|
||||
|
||||
// Prepare page markup
|
||||
.then(function() {
|
||||
return filetype.page.prepare(page.content)
|
||||
.then(function(content) {
|
||||
page.content = content;
|
||||
});
|
||||
})
|
||||
|
||||
// Generate template
|
||||
.then(function() {
|
||||
return that.template.renderPage(page);
|
||||
})
|
||||
|
||||
// Parse markup
|
||||
// Prepare and Parse markup
|
||||
.then(function(content) {
|
||||
page.content = content;
|
||||
|
||||
|
||||
+12
-5
@@ -96,17 +96,23 @@ 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 == "*") {
|
||||
that.book.log.warn.ln("you should specify a gitbook version to use in your book.json, for example: "+(_.first(pkg.version.split("."))+".x.x"));
|
||||
}
|
||||
|
||||
that.options.output = path.resolve(that.options.output || path.join(that.book.root, "_book"));
|
||||
that.options.plugins = normalizePluginsList(that.options.plugins);
|
||||
that.options.defaultsPlugins = normalizePluginsList(that.options.defaultsPlugins || "");
|
||||
that.options.plugins = _.union(that.options.plugins, that.options.defaultsPlugins);
|
||||
that.options.plugins = _.uniq(that.options.plugins, "name");
|
||||
|
||||
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 == "*") {
|
||||
that.book.log.warn.ln("you should specify a gitbook version to use in your book.json, for example: "+(_.first(pkg.version.split("."))+".x.x"));
|
||||
// Default value for text direction (from language)
|
||||
if (!that.options.direction) {
|
||||
var lang = i18n.getByLanguage(that.options.language);
|
||||
if (lang) that.options.direction = lang.direction;
|
||||
}
|
||||
|
||||
that.options.gitbook = pkg.version;
|
||||
@@ -141,6 +147,7 @@ Configuration.DEFAULT = {
|
||||
"description": null,
|
||||
"isbn": null,
|
||||
"language": "en",
|
||||
"direction": null,
|
||||
|
||||
// version of gitbook to use
|
||||
"gitbook": "*",
|
||||
|
||||
@@ -64,6 +64,8 @@ Generator.prototype.finish = function() {
|
||||
"--comments": that.options.description,
|
||||
"--isbn": that.options.isbn,
|
||||
"--authors": that.options.author,
|
||||
"--language": that.options.language,
|
||||
"--book-producer": "GitBook",
|
||||
"--publisher": "GitBook",
|
||||
"--chapter": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter ')]",
|
||||
"--chapter-mark": "pagebreak",
|
||||
@@ -91,6 +93,10 @@ Generator.prototype.finish = function() {
|
||||
"--pdf-header-template": String(pdfOptions.headerTemplate) || "<p class='header'><span>"+that.options.title+"</span></p>",
|
||||
"--pdf-footer-template": String(pdfOptions.footerTemplate) || "<p class='footer'><span>_SECTION_</span> <span style='float:right;'>_PAGENUM_</span></p>"
|
||||
});
|
||||
} else if (that.ebookFormat == "epub") {
|
||||
_.extend(_options, {
|
||||
"--dont-split-on-page-breaks": true
|
||||
});
|
||||
}
|
||||
|
||||
var command = [
|
||||
|
||||
+2
-1
@@ -318,7 +318,8 @@ TemplateEngine.prototype.renderString = function(content, context, options) {
|
||||
|
||||
// infos about gitbook
|
||||
gitbook: {
|
||||
version: pkg.version
|
||||
version: pkg.version,
|
||||
generator: this.book.options.generator
|
||||
}
|
||||
});
|
||||
options = _.defaults(options || {}, {
|
||||
|
||||
+3
-1
@@ -9,7 +9,9 @@ var getLocales = _.memoize(function() {
|
||||
return _.chain(locales)
|
||||
.map(function(local) {
|
||||
local = path.basename(local, ".json");
|
||||
return [local, _.extend(require(path.join(I18N_PATH, local)), {
|
||||
return [local, _.extend({
|
||||
direction: "ltr"
|
||||
}, require(path.join(I18N_PATH, local)), {
|
||||
id: local
|
||||
})];
|
||||
})
|
||||
|
||||
+11
-10
@@ -1,31 +1,32 @@
|
||||
var _ = require("lodash");
|
||||
var Q = require("q");
|
||||
var fs = require("./fs");
|
||||
var exec = require('child_process').exec;
|
||||
var spawn = require('spawn-cmd').spawn;
|
||||
|
||||
var links = require("./links");
|
||||
|
||||
// Convert a svg file
|
||||
var convertSVG = function(source, dest, options) {
|
||||
if (!fs.existsSync(source)) return Q.reject(new Error("File doesn't exist: "+source));
|
||||
|
||||
var d = Q.defer();
|
||||
|
||||
options = _.defaults(options || {}, {
|
||||
|
||||
});
|
||||
|
||||
var command = "svgexport "+source+" "+dest;
|
||||
//var command = shellescape(['svgexport', source, dest]);
|
||||
var child = spawn('svgexport', [source, dest]);
|
||||
|
||||
var child = exec(command, function (error, stdout, stderr) {
|
||||
if (error) {
|
||||
if (error.code == 127) error = new Error("Need to install 'svgexport' using 'npm install svgexport -g'");
|
||||
return d.reject(error);
|
||||
}
|
||||
if (fs.existsSync(dest)) {
|
||||
child.on("error", function(error) {
|
||||
if (error.code == "ENOENT") error = new Error("Need to install 'svgexport' using 'npm install svgexport -g'");
|
||||
return d.reject(error);
|
||||
});
|
||||
|
||||
child.on("close", function(code) {
|
||||
if (code == 0 && fs.existsSync(dest)) {
|
||||
d.resolve();
|
||||
} else {
|
||||
d.reject(new Error("Error converting "+source));
|
||||
d.reject(new Error("Error converting "+source+" into "+dest));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+21
-8
@@ -15,12 +15,27 @@ var isRelative = function(href) {
|
||||
try {
|
||||
var parsed = url.parse(href);
|
||||
|
||||
return !!(!parsed.protocol && parsed.path);// && parsed.path[0] != '/';
|
||||
return !!(!parsed.protocol && parsed.path);
|
||||
} catch(err) {}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// Return true if the link is an achor
|
||||
var isAnchor = function(href) {
|
||||
try {
|
||||
var parsed = url.parse(href);
|
||||
return !!(!parsed.protocol && !parsed.path && parsed.hash);
|
||||
} catch(err) {}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
// Normalize a path to be a link
|
||||
var normalizeLink = function(s) {
|
||||
return s.replace(/\\/g, '/');
|
||||
};
|
||||
|
||||
// Relative to absolute path
|
||||
// dir: directory parent of the file currently in rendering process
|
||||
// outdir: directory parent from the html output
|
||||
@@ -36,7 +51,7 @@ var toAbsolute = function(_href, dir, outdir) {
|
||||
_href = path.relative(outdir, hrefInRoot);
|
||||
|
||||
// Normalize windows paths
|
||||
_href = _href.replace(/\\/g, '/');
|
||||
_href = normalizeLink(_href);
|
||||
|
||||
return _href;
|
||||
};
|
||||
@@ -45,11 +60,7 @@ var toAbsolute = function(_href, dir, outdir) {
|
||||
var join = function() {
|
||||
var _href = path.join.apply(path, arguments);
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
_href = _href.replace(/\\/g, '/');
|
||||
}
|
||||
|
||||
return _href;
|
||||
return normalizeLink(_href);
|
||||
};
|
||||
|
||||
// Change extension
|
||||
@@ -61,9 +72,11 @@ var changeExtension = function(filename, newext) {
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
isAnchor: isAnchor,
|
||||
isRelative: isRelative,
|
||||
isExternal: isExternal,
|
||||
toAbsolute: toAbsolute,
|
||||
join: join,
|
||||
changeExtension: changeExtension
|
||||
changeExtension: changeExtension,
|
||||
normalize: normalizeLink
|
||||
};
|
||||
|
||||
+17
-9
@@ -1,5 +1,6 @@
|
||||
var Q = require('q');
|
||||
var _ = require('lodash');
|
||||
var url = require('url');
|
||||
var path = require('path');
|
||||
var cheerio = require('cheerio');
|
||||
var domSerializer = require('dom-serializer');
|
||||
@@ -104,7 +105,7 @@ function normalizeHtml(src, options) {
|
||||
// Generate filename
|
||||
dest = "/"+fs.getUniqueFilename(outputRoot, dest);
|
||||
|
||||
svgContent[dest] = content;
|
||||
svgContent[dest] = '<?xml version="1.0" encoding="UTF-8"?>'+content;
|
||||
$(this).replaceWith($("<img>").attr("src", dest));
|
||||
});
|
||||
}
|
||||
@@ -132,7 +133,7 @@ function normalizeHtml(src, options) {
|
||||
}
|
||||
|
||||
var ext = path.extname(src);
|
||||
var srcAbs = path.join("/", options.base, src);
|
||||
var srcAbs = links.join("/", options.base, src);
|
||||
|
||||
// Test image extension
|
||||
if (_.contains(imgUtils.INVALID, ext)) {
|
||||
@@ -144,7 +145,7 @@ function normalizeHtml(src, options) {
|
||||
var dest = "";
|
||||
|
||||
// Replace extension
|
||||
dest = path.join(path.dirname(srcAbs), path.basename(srcAbs, ext)+".png");
|
||||
dest = links.join(path.dirname(srcAbs), path.basename(srcAbs, ext)+".png");
|
||||
dest = dest[0] == "/"? dest.slice(1) : dest;
|
||||
|
||||
// Get a name that doesn't exists
|
||||
@@ -163,7 +164,7 @@ function normalizeHtml(src, options) {
|
||||
dest: path.join("./", dest)
|
||||
});
|
||||
|
||||
src = path.join("/", dest);
|
||||
src = links.join("/", dest);
|
||||
}
|
||||
|
||||
// Reset as relative to output
|
||||
@@ -186,15 +187,22 @@ function normalizeHtml(src, options) {
|
||||
var href = $(this).attr("href");
|
||||
if (!href) return;
|
||||
|
||||
if (links.isRelative(href)) {
|
||||
var absolutePath = path.join(options.base, href);
|
||||
if (links.isAnchor(href)) {
|
||||
// Keep it as it is
|
||||
} else if (links.isRelative(href)) {
|
||||
var parts = url.parse(path.join(options.base, href));
|
||||
var absolutePath = parts.pathname;
|
||||
var anchor = parts.hash;
|
||||
|
||||
// If is in navigation relative: change extsnio nto be .html
|
||||
if (options.navigation[absolutePath]) href = links.changeExtension(href, ".html");
|
||||
// If is in navigation relative: transform as content
|
||||
if (options.navigation[absolutePath]) {
|
||||
href = options.book.contentLink(href);
|
||||
}
|
||||
|
||||
// Transform as absolute
|
||||
href = links.toAbsolute(href, options.base, options.output);
|
||||
href = links.toAbsolute(href, options.base, options.output)+anchor;
|
||||
} else {
|
||||
// External links
|
||||
$(this).attr("target", "_blank");
|
||||
}
|
||||
|
||||
|
||||
+8
-7
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "2.0.0-alpha.9",
|
||||
"version": "2.0.0-beta.2",
|
||||
"homepage": "https://www.gitbook.com",
|
||||
"description": "Library and cmd utility to generate GitBooks",
|
||||
"main": "lib/index.js",
|
||||
@@ -10,10 +10,10 @@
|
||||
"lodash": "3.2.0",
|
||||
"graceful-fs": "3.0.5",
|
||||
"resolve": "0.6.3",
|
||||
"fs-extra": "0.16.3",
|
||||
"fs-extra": "0.16.5",
|
||||
"fstream-ignore": "1.0.2",
|
||||
"gitbook-parsers": "0.4.1",
|
||||
"nunjucks": "git+https://github.com/mozilla/nunjucks.git#42d2b9f5c0ad5db8ca3a1fdbba5bde9fc4cc2c45",
|
||||
"gitbook-parsers": "0.5.3",
|
||||
"nunjucks": "git+https://github.com/mozilla/nunjucks.git#0f8b21b8df7e8e852b2e1889388653b7075f0d09",
|
||||
"nunjucks-autoescape": "0.1.1",
|
||||
"nunjucks-filter": "0.1.0",
|
||||
"nunjucks-i18n": "1.0.0",
|
||||
@@ -30,10 +30,11 @@
|
||||
"URIjs": "1.14.1",
|
||||
"request": "2.51.0",
|
||||
"npm": "2.4.1",
|
||||
"dom-serializer": "0.1.0"
|
||||
"dom-serializer": "0.1.0",
|
||||
"spawn-cmd": "0.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "1.18.2",
|
||||
"mocha": "2.2.1",
|
||||
"grunt": "~0.4.2",
|
||||
"grunt-cli": "0.1.11",
|
||||
"grunt-contrib-copy": "0.5.0",
|
||||
@@ -42,7 +43,7 @@
|
||||
"grunt-bower-install-simple": "0.9.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "export TESTING=true; mocha --reporter list --timeout 15000"
|
||||
"test": "node_modules/.bin/mocha --reporter list --timeout 15000"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -13,6 +13,13 @@ describe('Links', function () {
|
||||
assert(!links.isExternal("/folder/test.md"));
|
||||
});
|
||||
|
||||
it('should correctly test anchor links', function() {
|
||||
assert(links.isAnchor("#test"));
|
||||
assert(links.isAnchor(" #test"));
|
||||
assert(!links.isAnchor("https://google.fr#test"));
|
||||
assert(!links.isAnchor("test.md#test"));
|
||||
});
|
||||
|
||||
describe('toAbsolute', function() {
|
||||
it('should correctly transform as absolute', function() {
|
||||
assert.equal(links.toAbsolute("http://google.fr"), "http://google.fr");
|
||||
|
||||
+2
-2
@@ -71,12 +71,12 @@ describe('Book parsing', function () {
|
||||
|
||||
assert.equal(_.size(NAVIGATION), 2);
|
||||
assert(NAVIGATION["intro.md"])
|
||||
assert.equal(NAVIGATION["intro.md"].title, "Introduction");
|
||||
assert.equal(NAVIGATION["intro.md"].title, "");
|
||||
assert.equal(NAVIGATION["intro.md"].prev, null);
|
||||
assert.equal(NAVIGATION["intro.md"].next.title, "Article 1");
|
||||
|
||||
assert.equal(NAVIGATION["sub/test1.md"].title, "Article 1");
|
||||
assert.equal(NAVIGATION["sub/test1.md"].prev.title, "Introduction");
|
||||
assert.equal(NAVIGATION["sub/test1.md"].prev.title, "");
|
||||
assert.equal(NAVIGATION["sub/test1.md"].next, null);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
var path = require('path');
|
||||
var _ = require('lodash');
|
||||
var assert = require('assert');
|
||||
var fs = require("fs");
|
||||
|
||||
var pkg = require("../package.json");
|
||||
|
||||
describe('Templating', function () {
|
||||
before(function(done) {
|
||||
testGeneration(books[0], "website", function(output) {}, done);
|
||||
});
|
||||
|
||||
var testTpl = function(str, args, options) {
|
||||
return books[0].template.renderString(str, args, options)
|
||||
.then(books[0].template.postProcess)
|
||||
};
|
||||
|
||||
it('should correctly have access to generator', function(done) {
|
||||
qdone(
|
||||
testTpl('{{ gitbook.generator }}')
|
||||
.then(function(content) {
|
||||
assert.equal(content, "website");
|
||||
}),
|
||||
done
|
||||
);
|
||||
});
|
||||
|
||||
it('should correctly have access to gitbook version', function(done) {
|
||||
qdone(
|
||||
testTpl('{{ gitbook.version }}')
|
||||
.then(function(content) {
|
||||
assert.equal(content, pkg.version.toString());
|
||||
}),
|
||||
done
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"direction": "rtl",
|
||||
"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": "بلا",
|
||||
"FONTSETTINGS_SERIF": "الرقيق"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"LANGS_CHOOSE": "ভাষা নির্বাচন করুন",
|
||||
"GLOSSARY": "গ্লোসারি",
|
||||
"GLOSSARY_INDEX": "ইন্ডেক্স",
|
||||
"GLOSSARY_OPEN": "গ্লোসারি",
|
||||
"GITBOOK_LINK": "গিটবুকের মাধ্যমে প্রকাশিত",
|
||||
"SUMMARY": "সূচিপত্র",
|
||||
"SUMMARY_INTRODUCTION": "সূচনা",
|
||||
"SUMMARY_TOGGLE": "সূচিপত্র",
|
||||
"SEARCH_TOGGLE": "অনুসন্ধান",
|
||||
"SEARCH_PLACEHOLDER": "অনুসন্ধান",
|
||||
"FONTSETTINGS_TOGGLE": "ফন্ট সেটিংস",
|
||||
"SHARE_TOGGLE": "শেয়ার",
|
||||
"SHARE_ON": "__platform__-এ শেয়ার",
|
||||
"FONTSETTINGS_WHITE": "সাদা",
|
||||
"FONTSETTINGS_SEPIA": "সেপিয়া",
|
||||
"FONTSETTINGS_NIGHT": "রাত",
|
||||
"FONTSETTINGS_SANS": "স্যান্স",
|
||||
"FONTSETTINGS_SERIF": "শেরিফ"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"LANGS_CHOOSE": "Choose a language",
|
||||
"GLOSSARY": "Glossary",
|
||||
"GLOSSARY_INDEX": "Index",
|
||||
"GLOSSARY_OPEN": "Glossary",
|
||||
"GITBOOK_LINK": "Published with GitBook",
|
||||
"SUMMARY": "Table of Contents",
|
||||
"SUMMARY_INTRODUCTION": "Introduction",
|
||||
"SUMMARY_TOGGLE": "Table of Contents",
|
||||
"SEARCH_TOGGLE": "Search",
|
||||
"SEARCH_PLACEHOLDER": "Type to search",
|
||||
"FONTSETTINGS_TOGGLE": "Font Settings",
|
||||
"SHARE_TOGGLE": "Share",
|
||||
"SHARE_ON": "Share on __platform__",
|
||||
"FONTSETTINGS_WHITE": "White",
|
||||
"FONTSETTINGS_SEPIA": "Sepia",
|
||||
"FONTSETTINGS_NIGHT": "Night",
|
||||
"FONTSETTINGS_SANS": "Sans",
|
||||
"FONTSETTINGS_SERIF": "Serif"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"direction": "rtl",
|
||||
"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": "سنس",
|
||||
"FONTSETTINGS_SERIF": "سریف"
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="{{ language }}" {% block htmlTag %}{% endblock %}>
|
||||
<html lang="{{ language }}" {% block htmlTag %}{% endblock %} {% if options.direction == "rtl" %}dir="rtl"{% endif %}>
|
||||
{{ htmlSnippet("html:start")|default("")|safe }}
|
||||
<head>
|
||||
{{ htmlSnippet("head:start")|default("")|safe }}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{% if item.level != "0" %}
|
||||
<b>{{ item.level }}.</b>
|
||||
{% endif %}
|
||||
{% if item.introduction %}{% i18n "SUMMARY_INTRODUCTION" %}Introduction{% endi18n %}{% else %}{{ item.title }}{% endif %}
|
||||
{% if item.introduction and not item.title %}{% i18n "SUMMARY_INTRODUCTION" %}Introduction{% endi18n %}{% else %}{{ item.title }}{% endif %}
|
||||
</a>
|
||||
{% else %}
|
||||
<a target="_blank" href="{{ item.path }}">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="{{ language }}">
|
||||
<html lang="{{ language }}" {% if options.direction == "rtl" %}dir="rtl"{% endif %}>
|
||||
{{ htmlSnippet("html:start")|default("")|safe }}
|
||||
<head>
|
||||
{{ htmlSnippet("head:start")|default("")|safe }}
|
||||
|
||||
Reference in New Issue
Block a user