diff options
-rw-r--r-- | README.md | 18 | ||||
-rw-r--r-- | lib/generate/fs.js | 2 | ||||
-rw-r--r-- | lib/generate/page/index.js | 3 | ||||
-rw-r--r-- | lib/generate/site/index.js | 3 | ||||
-rw-r--r-- | lib/parse/renderer.js | 24 |
5 files changed, 39 insertions, 11 deletions
@@ -91,26 +91,26 @@ An exercise is defined by 4 simple parts: Exercises need to start and finish with a separation bar (```---``` or ```***```). It should contain 3 code elements (**base**, **solution** and **validation**). --- - + Define a variable `x` equal to 10. - + ```js - var x = + var x = ``` - + ```js var x = 10; ``` - + ```js assert(x == 10); ``` - + --- #### Multi-Languages -GitBook supports generation of books written in multiple languages. Each languages should be a sub-directory with a normal GitBook format, and a file named `LANGS.md` should be present at the root of the repository with the following format: +GitBook supports building books written in multiple languages. Each language should be a sub-directory following the normal GitBook format, and a file named `LANGS.md` should be present at the root of the repository with the following format: ``` * [English](en/) @@ -119,3 +119,7 @@ GitBook supports generation of books written in multiple languages. Each languag ``` You can see a complete example with the [Learn Git](https://github.com/GitbookIO/git) book. + +#### Ignoring files & folders + +GitBook will read the `.gitignore`, `.bookignore` and `.ignore` files to get a list of files and folders to skip. (The format inside those files, follows the same convention as `.gitignore`) diff --git a/lib/generate/fs.js b/lib/generate/fs.js index 3338781..e06976b 100644 --- a/lib/generate/fs.js +++ b/lib/generate/fs.js @@ -11,7 +11,7 @@ var getFiles = function(path) { var ig = Ignore({ path: path, - ignoreFiles: ['.ignore', '.gitignore'] + ignoreFiles: ['.ignore', '.gitignore', '.bookignore'] }); // Add extra rules to ignore common folders diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js index 5be40c4..3ee368f 100644 --- a/lib/generate/page/index.js +++ b/lib/generate/page/index.js @@ -44,7 +44,8 @@ Generator.prototype.convertFile = function(content, input) { .then(function() { return parse.page(content, { repo: that.options.githubId, - dir: path.dirname(input) || '/' + dir: path.dirname(input) || '/', + outdir: './', }); }) .then(function(sections) { diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index 8b080f2..1cd63ff 100644 --- a/lib/generate/site/index.js +++ b/lib/generate/site/index.js @@ -94,7 +94,8 @@ Generator.prototype.convertFile = function(content, _input) { // Get HTML generated sections return parse.page(lexed, { repo: that.options.githubId, - dir: path.dirname(input) || '/' + dir: path.dirname(_input) || '/', + outdir: path.dirname(_input) || '/', }); }) .then(function(sections) { diff --git a/lib/parse/renderer.js b/lib/parse/renderer.js index 64c5602..848f6e3 100644 --- a/lib/parse/renderer.js +++ b/lib/parse/renderer.js @@ -45,7 +45,7 @@ GitBookRenderer.prototype.link = function(href, title, text) { var o = this._extra_options; // Relative link, rewrite it to point to github repo - if(parsed.path[0] != '/' && o && o.repo && o.dir) { + if(!parsed.protocol && parsed.path[0] != '/' && o && o.repo && o.dir) { href = 'https://github.com/' + o.repo + '/blob' + path.normalize(path.join( '/', o.dir, @@ -68,5 +68,27 @@ GitBookRenderer.prototype.link = function(href, title, text) { return out; }; +GitBookRenderer.prototype.image = function(href, title, text) { + // Our "fixed" href + var _href = href; + + // Parsed version of the url + var parsed = url.parse(href); + + // Options + var o = this._extra_options; + + // Relative image, rewrite it depending output + if(!parsed.protocol && parsed.path[0] != '/' && o && o.dir && o.outdir) { + _href = path.relative(o.outdir, path.normalize(path.join( + o.dir, + href + ))); + } + + return GitBookRenderer.super_.prototype.image.call(this, _href, title, text); +}; + + // Exports module.exports = GitBookRenderer; |