Compare commits

...

10 Commits

Author SHA1 Message Date
Samy Pessé b629b78dba Bump version to 0.7.0 2014-08-01 13:58:36 -07:00
Samy Pessé f62c218735 Fix #278: Add page break between chapters/articles 2014-08-01 13:55:19 -07:00
Aaron O'Mullan 725510028f Use marked-text-renderer@0.1.0 2014-08-01 00:09:45 -07:00
Aaron O'Mullan ad7927242d Add comments to default introduction chapter code
Fixes #388
2014-07-31 08:43:57 -07:00
Aaron O'Mullan 5692bdd229 Merge pull request #386 from codepiano/china-social-network-sharing
add sharing to weibo.com.
2014-07-31 01:41:56 -07:00
codepiano 3402746719 add sharing to weibo.com.
google、facebook and twitter are block by GFW in China,Chinese can
not visit these websites.
add 'weibo' config in option links.sharing,the share link will not be
used by default,users should set the value of 'weibo' to true to turn
on sharing to weibo.com.
2014-07-31 16:31:31 +08:00
Aaron O'Mullan 30a8414b06 Switch to graceful-fs, fix #373 2014-07-30 20:45:33 -07:00
Aaron O'Mullan 9d46899ea7 Replace "marked" with "kramed" 2014-07-30 16:17:47 -07:00
Samy Pessé 58f14fd9ca Fix font settings apply 2014-07-30 11:17:28 -07:00
Samy Pessé b6af14b13e Remove github count stars and watchers 2014-07-30 10:43:10 -07:00
16 changed files with 45 additions and 58 deletions
+5 -2
View File
@@ -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
View File
@@ -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");
+4 -4
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
var fs = require('fs');
var fs = require('graceful-fs');
var path = require('path');
module.exports = function(code, folder) {
+2 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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
}));
}
+2 -2
View File
@@ -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 = '';
+6 -4
View File
@@ -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(
+4 -3
View File
@@ -1,19 +1,20 @@
{
"name": "gitbook",
"version": "0.6.3",
"version": "0.7.0",
"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",
"graceful-fs": "3.0.2",
"fs-extra": "0.8.1",
"highlight.js": "8.0.0",
"tmp": "0.0.23",
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-20
View File
@@ -9,7 +9,6 @@ define([
"core/loading"
], function($, URL, events, state, progress, exercises, quiz, loading) {
var prev, next;
var githubCountStars, githubCountWatch;
var usePushState = (typeof history.pushState !== "undefined");
@@ -63,11 +62,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 +89,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");
};
+4 -1
View File
@@ -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
};
});
});
+6 -6
View File
@@ -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;
}
}
+2 -4
View File
@@ -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 -->