mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-26 20:27:00 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d46bd14678 | |||
| b3e5b3d106 | |||
| b830ef5dca | |||
| 45326c4ad2 |
@@ -171,5 +171,5 @@ Plugins can used to extend your book functionnalities. Read [GitbookIO/plugin](h
|
||||
|
||||
* [Google Analytics](https://github.com/GitbookIO/plugin-ga): Google Analytics tracking for your book
|
||||
* [Disqus](https://github.com/GitbookIO/plugin-disqus): Disqus comments integration in your book
|
||||
* [Transform comments to notes](https://github.com/erixtekila/gitbook-plugin-comments): Allow markdown comments to be inserted in HTML output
|
||||
* [Transform annoted quotes to notes](https://github.com/erixtekila/gitbook-plugin-richquotes): Allow extra markdown markup to render blockquotes as nice notes
|
||||
* [Send code to console](https://github.com/erixtekila/gitbook-plugin-toconsole): Evaluate javascript blockin the browser inspector's console
|
||||
|
||||
+26
-20
@@ -100,7 +100,6 @@ Generator.prototype.indexPage = function(lexed, pagePath) {
|
||||
// Convert a markdown file to html
|
||||
Generator.prototype.convertFile = function(content, _input) {
|
||||
var that = this;
|
||||
var progress = parse.progress(this.options.navigation, _input);
|
||||
|
||||
_output = _input.replace(".md", ".html");
|
||||
if (_output == "README.html") _output = "index.html";
|
||||
@@ -109,19 +108,28 @@ Generator.prototype.convertFile = function(content, _input) {
|
||||
var output = path.join(this.options.output, _output);
|
||||
var basePath = path.relative(path.dirname(output), this.options.output) || ".";
|
||||
|
||||
var page = {
|
||||
path: _input,
|
||||
content: content,
|
||||
progress: parse.progress(this.options.navigation, _input)
|
||||
};
|
||||
|
||||
var _callHook = function(name) {
|
||||
return that.callHook("page:before", page)
|
||||
.then(function(_page) {
|
||||
page = _page;
|
||||
return page;
|
||||
});
|
||||
};
|
||||
|
||||
return Q()
|
||||
.then(function() {
|
||||
// Send content to plugins
|
||||
return that.callHook("page:before", {
|
||||
path: _input,
|
||||
content: content
|
||||
});
|
||||
return _callHook("page:before");
|
||||
})
|
||||
.then(function(_content) {
|
||||
content = _content.content;
|
||||
|
||||
.then(function() {
|
||||
// Lex page
|
||||
return parse.lex(content);
|
||||
return parse.lex(page.content);
|
||||
})
|
||||
.then(function(lexed) {
|
||||
// Index page in search
|
||||
@@ -137,28 +145,26 @@ Generator.prototype.convertFile = function(content, _input) {
|
||||
});
|
||||
})
|
||||
.then(function(sections) {
|
||||
page.sections = sections;
|
||||
|
||||
// Use plugin hook
|
||||
return that.callHook("page", {
|
||||
path: _input,
|
||||
sections: sections
|
||||
})
|
||||
return _callHook("page");
|
||||
})
|
||||
.then(function(_page) {
|
||||
.then(function() {
|
||||
that.manifest.add("CACHE", _output);
|
||||
|
||||
return that._writeTemplate(that.template, {
|
||||
progress: _page.progress,
|
||||
progress: page.progress,
|
||||
|
||||
_input: _input,
|
||||
content: _page.sections,
|
||||
content: page.sections,
|
||||
|
||||
basePath: basePath,
|
||||
staticBase: path.join(basePath, "gitbook"),
|
||||
}, output, function(html) {
|
||||
return that.callHook("page:after", {
|
||||
path: _input,
|
||||
content: html
|
||||
}).get("content")
|
||||
page.content = html;
|
||||
|
||||
return _callHook("page:after").get("content")
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.1",
|
||||
"homepage": "http://www.gitbook.io/",
|
||||
"description": "Library and cmd utility to generate GitBooks",
|
||||
"main": "lib/index.js",
|
||||
|
||||
Reference in New Issue
Block a user