mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-27 12:39:08 +00:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 633e52c4be | |||
| 1512bcf808 | |||
| 4e46d088ca | |||
| 388c7ffd32 | |||
| 7ba8653935 | |||
| a4403aad1e | |||
| b629b78dba | |||
| f62c218735 | |||
| 725510028f | |||
| ad7927242d | |||
| 5692bdd229 | |||
| 3402746719 | |||
| 30a8414b06 | |||
| 9d46899ea7 | |||
| 58f14fd9ca | |||
| b6af14b13e | |||
| ba2134c480 | |||
| 4705548860 | |||
| 7d51ae3689 |
+15
@@ -1,5 +1,20 @@
|
||||
# Release notes
|
||||
|
||||
## 0.7.1
|
||||
- Update `fs-extra` to `0.10.0` (fixes potential race conditions)
|
||||
|
||||
## 0.7.0
|
||||
- Add page break in ebook (pdf, epub, mobi) between chapters/articles
|
||||
- Start using kramed instead of marked
|
||||
- Fix display of inline math
|
||||
- Switch to graceful-fs to fix EMFILE errors
|
||||
- Add sharing to weibo.com
|
||||
|
||||
## 0.6.2
|
||||
- Support generating a plugin's book info dynamically
|
||||
- Improve navigation on dark theme
|
||||
- Improve path normalization when parsing SUMMARY.md
|
||||
|
||||
## 0.6.0
|
||||
- Generate header id the same as github
|
||||
- Custom links can be added at top of sidebar
|
||||
|
||||
@@ -4,7 +4,7 @@ var Q = require("q");
|
||||
var _ = require("lodash");
|
||||
var exec = require('child_process').exec;
|
||||
|
||||
var fs = require("fs");
|
||||
var fs = require('graceful-fs');
|
||||
var parse = require("../../parse");
|
||||
var BaseGenerator = require("../page");
|
||||
var stringUtils = require("../../utils/string");
|
||||
@@ -35,9 +35,12 @@ Generator.prototype.finish = function() {
|
||||
"--title": that.options.title,
|
||||
"--comments": that.options.description,
|
||||
"--authors": that.options.author,
|
||||
"--chapter": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter ')]",
|
||||
"--chapter-mark": "pagebreak",
|
||||
"--level1-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-1 ')]",
|
||||
"--level2-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-2 ')]",
|
||||
"--level3-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-3 ')]"
|
||||
"--level3-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-3 ')]",
|
||||
"--no-chapters-in-toc": true
|
||||
};
|
||||
|
||||
if (format == "pdf") {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
var Q = require("q");
|
||||
var fs = require("fs");
|
||||
var fs = require('graceful-fs');
|
||||
var fsExtra = require("fs-extra");
|
||||
var Ignore = require("fstream-ignore");
|
||||
|
||||
|
||||
+19
-3
@@ -65,7 +65,7 @@ Plugin.prototype.normalizeResource = function(resource) {
|
||||
};
|
||||
|
||||
// Return resources
|
||||
Plugin.prototype.getResources = function() {
|
||||
Plugin.prototype._getResources = function() {
|
||||
var book = this.infos.book;
|
||||
|
||||
// Nothing specified, fallback to default
|
||||
@@ -80,7 +80,24 @@ Plugin.prototype.getResources = function() {
|
||||
}
|
||||
|
||||
// Plain data object
|
||||
return Q(book);
|
||||
return Q(_.cloneDeep(book));
|
||||
};
|
||||
|
||||
// Normalize resources and return them
|
||||
Plugin.prototype.getResources = function() {
|
||||
var that = this;
|
||||
|
||||
|
||||
|
||||
return this._getResources()
|
||||
.then(function(resources) {
|
||||
|
||||
_.each(RESOURCES, function(resourceType) {
|
||||
resources[resourceType] = (resources[resourceType] || []).map(that.normalizeResource);
|
||||
});
|
||||
|
||||
return resources;
|
||||
});
|
||||
};
|
||||
|
||||
// Test if it's a valid plugin
|
||||
@@ -165,7 +182,6 @@ Plugin.normalizeNames = function(names) {
|
||||
|
||||
// Extract data from a list of plugin
|
||||
Plugin.fromList = function(names, root, generator) {
|
||||
var that = this;
|
||||
var failed = [];
|
||||
|
||||
// Load plugins
|
||||
|
||||
@@ -202,12 +202,12 @@ Generator.prototype.copyAssets = function() {
|
||||
return plugin.copyAssets(pluginAssets)
|
||||
.then(function(copiedStuff) {
|
||||
// Nothing was copied
|
||||
if(!copiedStuff) return;
|
||||
if(!copiedStuff) { return; }
|
||||
return that.manifest.addFolder(pluginAssets, "gitbook/plugins/"+plugin.name);
|
||||
});
|
||||
})
|
||||
);
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
// Dump search index to disk
|
||||
|
||||
@@ -2,7 +2,7 @@ var Q = require("q");
|
||||
var _ = require("lodash");
|
||||
|
||||
var lunr = require('lunr');
|
||||
var marked = require('marked');
|
||||
var kramed = require('kramed');
|
||||
var textRenderer = require('marked-text-renderer');
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ Indexer.prototype.text = function(nodes) {
|
||||
// Copy section
|
||||
var section = _.toArray(nodes);
|
||||
|
||||
// marked's Render expects this, we don't use it yet
|
||||
// kramed's Render expects this, we don't use it yet
|
||||
section.links = {};
|
||||
|
||||
var options = _.extend({}, marked.defaults, {
|
||||
var options = _.extend({}, kramed.defaults, {
|
||||
renderer: this.renderer
|
||||
});
|
||||
|
||||
return marked.parser(section, options);
|
||||
return kramed.parser(section, options);
|
||||
};
|
||||
|
||||
Indexer.prototype.addSection = function(path, section) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var fs = require('fs');
|
||||
var fs = require('graceful-fs');
|
||||
var path = require('path');
|
||||
|
||||
module.exports = function(code, folder) {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
var _ = require('lodash');
|
||||
var marked = require('marked');
|
||||
var kramed = require('kramed');
|
||||
|
||||
// Split a page up into sections (lesson, exercises, ...)
|
||||
function splitSections(nodes) {
|
||||
@@ -88,7 +88,7 @@ function sectionId(section, idx) {
|
||||
|
||||
function lexPage(src) {
|
||||
// Lex file
|
||||
var nodes = marked.lexer(src);
|
||||
var nodes = kramed.lexer(src);
|
||||
|
||||
return _.chain(splitSections(nodes))
|
||||
.map(function(section, idx) {
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
var _ = require('lodash');
|
||||
var marked = require('marked');
|
||||
var kramed = require('kramed');
|
||||
var hljs = require('highlight.js');
|
||||
|
||||
var lex = require('./lex');
|
||||
@@ -18,7 +18,7 @@ function render(section, _options) {
|
||||
section.links = links;
|
||||
|
||||
// Build options using defaults and our custom renderer
|
||||
var options = _.extend({}, marked.defaults, {
|
||||
var options = _.extend({}, kramed.defaults, {
|
||||
renderer: renderer(null, _options),
|
||||
|
||||
// Synchronous highlighting with highlight.js
|
||||
@@ -36,7 +36,7 @@ function render(section, _options) {
|
||||
}
|
||||
});
|
||||
|
||||
return marked.parser(section, options);
|
||||
return kramed.parser(section, options);
|
||||
}
|
||||
|
||||
function quizQuestion(node) {
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
var _ = require('lodash');
|
||||
var marked = require('marked');
|
||||
var kramed = require('kramed');
|
||||
var textRenderer = require('marked-text-renderer');
|
||||
|
||||
function extractFirstNode(nodes, nType) {
|
||||
@@ -18,7 +18,7 @@ function parseReadme(src) {
|
||||
var renderer = textRenderer();
|
||||
|
||||
// Parse content
|
||||
nodes = marked.lexer(src);
|
||||
nodes = kramed.lexer(src);
|
||||
|
||||
title = extractFirstNode(nodes, "heading") || '';
|
||||
description = extractFirstNode(nodes, "paragraph") || '';
|
||||
@@ -28,7 +28,7 @@ function parseReadme(src) {
|
||||
return _.unescape(text.replace(/(\r\n|\n|\r)/gm, ""));
|
||||
},
|
||||
function(text) {
|
||||
return marked.parse(text, _.extend({}, marked.defaults, {
|
||||
return kramed.parse(text, _.extend({}, kramed.defaults, {
|
||||
renderer: renderer
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ var codeInclude = require('./code_include');
|
||||
|
||||
var path = require('path');
|
||||
|
||||
var marked = require('marked');
|
||||
var kramed = require('kramed');
|
||||
|
||||
var rendererId = 0;
|
||||
|
||||
@@ -21,7 +21,7 @@ function GitBookRenderer(options, extra_options) {
|
||||
this.id = rendererId++;
|
||||
this.quizIndex = 0;
|
||||
}
|
||||
inherits(GitBookRenderer, marked.Renderer);
|
||||
inherits(GitBookRenderer, kramed.Renderer);
|
||||
|
||||
GitBookRenderer.prototype._unsanitized = function(href) {
|
||||
var prot = '';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var _ = require('lodash');
|
||||
var marked = require('marked');
|
||||
var kramed = require('kramed');
|
||||
|
||||
|
||||
// Utility function for splitting a list into groups
|
||||
@@ -43,7 +43,7 @@ function listSplit(nodes, start_type, end_type) {
|
||||
}
|
||||
|
||||
// Get the biggest list
|
||||
// out of a list of marked nodes
|
||||
// out of a list of kramed nodes
|
||||
function filterList(nodes) {
|
||||
return _.chain(nodes)
|
||||
.toArray()
|
||||
@@ -64,7 +64,7 @@ function filterList(nodes) {
|
||||
// supports extracting links
|
||||
function parseTitle(src, nums) {
|
||||
// Check if it's a link
|
||||
var matches = marked.InlineLexer.rules.link.exec(src);
|
||||
var matches = kramed.InlineLexer.rules.link.exec(src);
|
||||
|
||||
var level = nums.join('.');
|
||||
|
||||
@@ -102,6 +102,7 @@ function parseChapter(nodes, nums) {
|
||||
function defaultChapterList(chapterList) {
|
||||
var first = _.first(chapterList);
|
||||
|
||||
// Check if introduction node was specified in SUMMARY.md
|
||||
if (first) {
|
||||
var chapter = parseChapter(first, [0]);
|
||||
|
||||
@@ -111,13 +112,14 @@ function defaultChapterList(chapterList) {
|
||||
}
|
||||
}
|
||||
|
||||
// It wasn't specified, so add in default
|
||||
return [
|
||||
[ { type: 'text', text: '[Introduction](README.md)' } ]
|
||||
].concat(chapterList);
|
||||
}
|
||||
|
||||
function listGroups(src) {
|
||||
var nodes = marked.lexer(src);
|
||||
var nodes = kramed.lexer(src);
|
||||
|
||||
// Get out groups of lists
|
||||
return listSplit(
|
||||
|
||||
+5
-4
@@ -1,20 +1,21 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "0.6.2",
|
||||
"version": "0.7.1",
|
||||
"homepage": "http://www.gitbook.io/",
|
||||
"description": "Library and cmd utility to generate GitBooks",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"q": "1.0.1",
|
||||
"lodash": "2.4.1",
|
||||
"marked": "0.3.2",
|
||||
"marked-text-renderer": "0.0.1",
|
||||
"kramed": "0.4.0",
|
||||
"marked-text-renderer": "0.1.0",
|
||||
"lunr": "0.5.2",
|
||||
"swig": "1.3.2",
|
||||
"send": "0.2.0",
|
||||
"fstream-ignore": "0.0.7",
|
||||
"commander": "2.2.0",
|
||||
"fs-extra": "0.8.1",
|
||||
"graceful-fs": "3.0.2",
|
||||
"fs-extra": "0.10.0",
|
||||
"highlight.js": "8.0.0",
|
||||
"tmp": "0.0.23",
|
||||
"semver": "2.2.1",
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -6,10 +6,10 @@ define([
|
||||
"core/progress",
|
||||
"core/exercise",
|
||||
"core/quiz",
|
||||
"core/loading"
|
||||
], function($, URL, events, state, progress, exercises, quiz, loading) {
|
||||
"core/loading",
|
||||
"core/search"
|
||||
], function($, URL, events, state, progress, exercises, quiz, loading, search) {
|
||||
var prev, next;
|
||||
var githubCountStars, githubCountWatch;
|
||||
|
||||
var usePushState = (typeof history.pushState !== "undefined");
|
||||
|
||||
@@ -56,6 +56,8 @@ define([
|
||||
|
||||
// Update state
|
||||
state.update($("html"));
|
||||
// recover search keyword
|
||||
search.recover();
|
||||
preparePage();
|
||||
})
|
||||
.fail(function (e) {
|
||||
@@ -63,11 +65,6 @@ define([
|
||||
}));
|
||||
};
|
||||
|
||||
var updateGitHubCounts = function() {
|
||||
$(".book-header .count-star span").text(githubCountStars);
|
||||
$(".book-header .count-watch span").text(githubCountWatch);
|
||||
};
|
||||
|
||||
var updateNavigationPosition = function() {
|
||||
var bodyInnerWidth, pageWrapperWidth;
|
||||
|
||||
@@ -95,20 +92,6 @@ define([
|
||||
// Focus on content
|
||||
$pageWrapper.focus();
|
||||
|
||||
// Update GitHub count
|
||||
if (state.githubId) {
|
||||
if (githubCountStars) {
|
||||
updateGitHubCounts();
|
||||
} else {
|
||||
$.getJSON("https://api.github.com/repos/"+state.githubId)
|
||||
.done(function(repo) {
|
||||
githubCountStars = repo.stargazers_count;
|
||||
githubCountWatch = repo.subscribers_count;
|
||||
updateGitHubCounts();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Send to mixpanel
|
||||
events.trigger("page.change");
|
||||
};
|
||||
@@ -166,4 +149,5 @@ define([
|
||||
goNext: goNext,
|
||||
goPrev: goPrev
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -81,18 +81,34 @@ define([
|
||||
}
|
||||
if (q.length == 0) {
|
||||
sidebar.filter(null);
|
||||
storage.remove("keyword");
|
||||
} else {
|
||||
var results = search(q);
|
||||
sidebar.filter(
|
||||
_.pluck(results, "path")
|
||||
);
|
||||
storage.set("keyword", q);
|
||||
}
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
// filter sidebar menu with current search keyword
|
||||
var recoverSearch = function() {
|
||||
var keyword = storage.get("keyword", "");
|
||||
if(keyword.length > 0) {
|
||||
if(!isSearchOpen()){
|
||||
toggleSearch();
|
||||
}
|
||||
sidebar.filter(_.pluck(search(keyword), "path"));
|
||||
}
|
||||
$(".book-search input").val(keyword);
|
||||
};
|
||||
|
||||
return {
|
||||
init: init,
|
||||
search: search,
|
||||
toggle: toggleSearch
|
||||
toggle: toggleSearch,
|
||||
recover:recoverSearch
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,6 +13,9 @@ define([
|
||||
},
|
||||
"google-plus": function($el) {
|
||||
window.open("https://plus.google.com/share?url="+encodeURIComponent(url))
|
||||
},
|
||||
"weibo": function($el) {
|
||||
window.open("http://service.weibo.com/share/share.php?content=utf-8&url="+encodeURIComponent(url)+"&title="+encodeURIComponent(title))
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,4 +33,4 @@ define([
|
||||
return {
|
||||
init: init
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -103,27 +103,27 @@
|
||||
}
|
||||
|
||||
&.font-size-0 {
|
||||
.book-body {
|
||||
.book-body .page-inner section {
|
||||
font-size:@s-font-size;
|
||||
}
|
||||
}
|
||||
&.font-size-1 {
|
||||
.book-body {
|
||||
.book-body .page-inner section {
|
||||
font-size:@m-font-size;
|
||||
}
|
||||
}
|
||||
&.font-size-2 {
|
||||
.book-body {
|
||||
.book-body .page-inner section {
|
||||
font-size:@l-font-size;
|
||||
}
|
||||
}
|
||||
&.font-size-3 {
|
||||
.book-body {
|
||||
&.font-size-3{
|
||||
.book-body .page-inner section {
|
||||
font-size:@xl-font-size;
|
||||
}
|
||||
}
|
||||
&.font-size-4 {
|
||||
.book-body {
|
||||
.book-body .page-inner section {
|
||||
font-size:@xxl-font-size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,8 @@
|
||||
{% if options.links.sharing.twitter !== false %}
|
||||
<a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="twitter" aria-label="Share on Twitter"><i class="fa fa-twitter"></i></a>
|
||||
{% endif %}
|
||||
|
||||
{% if githubId %}
|
||||
<a href="{{ githubHost }}{{ githubId }}/stargazers" target="_blank" class="btn pull-right count-star hidden-xs"><i class="fa fa-star-o"></i> Star (<span>-</span>)</a>
|
||||
<a href="{{ githubHost }}{{ githubId }}/watchers" target="_blank" class="btn pull-right count-watch hidden-xs"><i class="fa fa-eye"></i> Watch (<span>-</span>)</a>
|
||||
{% if options.links.sharing.weibo === true %}
|
||||
<a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="weibo" aria-label="Share on Weibo"><i class="fa fa-weibo"></i></a>
|
||||
{% endif %}
|
||||
|
||||
<!-- Title -->
|
||||
|
||||
Reference in New Issue
Block a user