mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-30 22:18:46 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b698d43d7d | |||
| a36b9a6088 | |||
| 20acd89c8a | |||
| 7bed9a257d | |||
| 19c83aa5a8 | |||
| 52610d7d61 | |||
| 9e4b393b7a | |||
| a0ae34a3b7 | |||
| 413dc5d004 | |||
| c9eb27bfe7 | |||
| b78505c290 | |||
| 95f9ae83d0 | |||
| 9304289315 | |||
| 1b726ca293 | |||
| 656ca18929 |
@@ -35,7 +35,6 @@ Options for commands `build` and `serve` are:
|
|||||||
-g, --github <repo_path> ID of github repo like : username/repo
|
-g, --github <repo_path> ID of github repo like : username/repo
|
||||||
-o, --output <directory> Path to output directory, defaults to ./_book
|
-o, --output <directory> Path to output directory, defaults to ./_book
|
||||||
-f, --format <name> Change generation format, defaults to site, availables are: site, page, pdf, json
|
-f, --format <name> Change generation format, defaults to site, availables are: site, page, pdf, json
|
||||||
-i, --intro <intro> Description of the book to generate
|
|
||||||
--githubHost <url> The url of the github host (defaults to https://github.com/)
|
--githubHost <url> The url of the github host (defaults to https://github.com/)
|
||||||
--theme <path> Path to theme directory
|
--theme <path> Path to theme directory
|
||||||
```
|
```
|
||||||
|
|||||||
+2
-1
@@ -16,7 +16,8 @@ var getFiles = function(path) {
|
|||||||
|
|
||||||
// Add extra rules to ignore common folders
|
// Add extra rules to ignore common folders
|
||||||
ig.addIgnoreRules([
|
ig.addIgnoreRules([
|
||||||
'.git/'
|
'.git/',
|
||||||
|
'.gitignore',
|
||||||
], '__custom_stuff');
|
], '__custom_stuff');
|
||||||
|
|
||||||
// Push each file to our list
|
// Push each file to our list
|
||||||
|
|||||||
+11
-2
@@ -129,6 +129,15 @@ var generate = function(options) {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Skip processing some files
|
||||||
|
.then(function() {
|
||||||
|
files = _.filter(files, function (file) {
|
||||||
|
return !(
|
||||||
|
file === 'SUMMARY.md'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
// Copy file and replace markdown file
|
// Copy file and replace markdown file
|
||||||
.then(function() {
|
.then(function() {
|
||||||
return Q.all(
|
return Q.all(
|
||||||
@@ -177,7 +186,7 @@ var generateFile = function(options) {
|
|||||||
return Q.nfcall(tmp.dir)
|
return Q.nfcall(tmp.dir)
|
||||||
.then(function(tmpDir) {
|
.then(function(tmpDir) {
|
||||||
return generate(
|
return generate(
|
||||||
_.extend({},
|
_.extend({},
|
||||||
options,
|
options,
|
||||||
{
|
{
|
||||||
output: tmpDir
|
output: tmpDir
|
||||||
@@ -195,7 +204,7 @@ var generateFile = function(options) {
|
|||||||
_outputFile = _outputFile.slice(0, -path.extname(_outputFile).length)+"_"+lang+path.extname(_outputFile);
|
_outputFile = _outputFile.slice(0, -path.extname(_outputFile).length)+"_"+lang+path.extname(_outputFile);
|
||||||
_tmpDir = path.join(_tmpDir, lang);
|
_tmpDir = path.join(_tmpDir, lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fs.copy(
|
return fs.copy(
|
||||||
path.join(_tmpDir, "index."+ext),
|
path.join(_tmpDir, "index."+ext),
|
||||||
_outputFile
|
_outputFile
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ function isQuiz(nodes) {
|
|||||||
|
|
||||||
if(
|
if(
|
||||||
// List of questions
|
// List of questions
|
||||||
listIdx !== -1 && isQuizNode(quizNodes[listIdx + 1]) &&
|
listIdx !== -1 && isQuizNode(quizNodes[listIdx + 1]) ||
|
||||||
|
|
||||||
// Table of questions
|
// Table of questions
|
||||||
(
|
(
|
||||||
|
|||||||
+15
-12
@@ -8,17 +8,6 @@ var renderer = require('./renderer');
|
|||||||
var lnormalize = require('../utils/lang').normalize;
|
var lnormalize = require('../utils/lang').normalize;
|
||||||
|
|
||||||
|
|
||||||
// Synchronous highlighting with highlight.js
|
|
||||||
marked.setOptions({
|
|
||||||
highlight: function (code, lang) {
|
|
||||||
try {
|
|
||||||
return hljs.highlight(lang, code).value;
|
|
||||||
} catch(e) {
|
|
||||||
return hljs.highlightAuto(code).value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Render a section using our custom renderer
|
// Render a section using our custom renderer
|
||||||
function render(section, _options) {
|
function render(section, _options) {
|
||||||
@@ -30,7 +19,21 @@ function render(section, _options) {
|
|||||||
|
|
||||||
// Build options using defaults and our custom renderer
|
// Build options using defaults and our custom renderer
|
||||||
var options = _.extend({}, marked.defaults, {
|
var options = _.extend({}, marked.defaults, {
|
||||||
renderer: renderer(null, _options)
|
renderer: renderer(null, _options),
|
||||||
|
|
||||||
|
// Synchronous highlighting with highlight.js
|
||||||
|
highlight: function (code, lang) {
|
||||||
|
if(!lang) return code;
|
||||||
|
|
||||||
|
// Normalize lang
|
||||||
|
lang = lnormalize(lang);
|
||||||
|
|
||||||
|
try {
|
||||||
|
return hljs.highlight(lang, code).value;
|
||||||
|
} catch(e) { }
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return marked.parser(section, options);
|
return marked.parser(section, options);
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gitbook",
|
"name": "gitbook",
|
||||||
"version": "0.2.0",
|
"version": "0.2.1",
|
||||||
"description": "Library and cmd utility to generate GitBooks",
|
"description": "Library and cmd utility to generate GitBooks",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 164 KiB |
Vendored
+15
@@ -31,3 +31,18 @@ Some more nice content ....
|
|||||||
[Cool stuff](http://gitbook.io)
|
[Cool stuff](http://gitbook.io)
|
||||||
|
|
||||||
[Link to another Markdown file](./xyz/file.md)
|
[Link to another Markdown file](./xyz/file.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Quiz test 2: What does Gitbook support?
|
||||||
|
- [x] Table-based questions with radio buttons
|
||||||
|
- [x] Table-based questions with checkboxes
|
||||||
|
- [ ] Telepathy
|
||||||
|
- [x] List-based questions with checkboxes
|
||||||
|
- [x] List-based questions with radio buttons
|
||||||
|
- [ ] Moon-on-a-stick
|
||||||
|
|
||||||
|
> Gitbook supports table and list based quiz questions using either radio buttons or checkboxes.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ describe('Page parsing', function() {
|
|||||||
assert.equal(QUIZ_LEXED[0].type, 'normal');
|
assert.equal(QUIZ_LEXED[0].type, 'normal');
|
||||||
assert.equal(QUIZ_LEXED[1].type, 'quiz');
|
assert.equal(QUIZ_LEXED[1].type, 'quiz');
|
||||||
assert.equal(QUIZ_LEXED[2].type, 'normal');
|
assert.equal(QUIZ_LEXED[2].type, 'normal');
|
||||||
|
assert.equal(QUIZ_LEXED[3].type, 'quiz');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should gen content for normal sections', function() {
|
it('should gen content for normal sections', function() {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -38,10 +38,17 @@ define([
|
|||||||
});
|
});
|
||||||
$("head").html(headContent);
|
$("head").html(headContent);
|
||||||
|
|
||||||
// Update header, body and summary
|
// Update header, body
|
||||||
$('.book-header').html($page.find('.book-header').html());
|
$('.book-header').html($page.find('.book-header').html());
|
||||||
$('.book-body').html($page.find('.book-body').html());
|
$('.book-body').html($page.find('.book-body').html());
|
||||||
|
|
||||||
|
// Update summary
|
||||||
|
var scrollPosition = $('.book-summary .summary').scrollTop();
|
||||||
$('.book-summary').html($page.find('.book-summary').html());
|
$('.book-summary').html($page.find('.book-summary').html());
|
||||||
|
$('.book-summary .summary').scrollTop(scrollPosition);
|
||||||
|
|
||||||
|
// Update state
|
||||||
|
state.update($page);
|
||||||
|
|
||||||
if (push) updateHistory(url, null);
|
if (push) updateHistory(url, null);
|
||||||
preparePage();
|
preparePage();
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
define([
|
define([
|
||||||
"jQuery"
|
"jQuery"
|
||||||
], function() {
|
], function() {
|
||||||
var $book = $(".book");
|
var state = {};
|
||||||
|
|
||||||
return {
|
state.update = function(dom) {
|
||||||
'$book': $book,
|
var $book = $(dom.find(".book"));
|
||||||
|
|
||||||
'githubId': $book.data("github"),
|
state.$book = $book;
|
||||||
'level': $book.data("level"),
|
state.githubId = $book.data("github");
|
||||||
'basePath': $book.data("basepath"),
|
state.level = $book.data("level");
|
||||||
'revision': $book.data("revision")
|
state.basePath = $book.data("basepath");
|
||||||
|
state.revision = $book.data("revision");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
state.update($);
|
||||||
|
|
||||||
|
return state;
|
||||||
});
|
});
|
||||||
@@ -37,8 +37,6 @@
|
|||||||
padding: 10px 5px;
|
padding: 10px 5px;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
||||||
border-bottom: 1px solid #eee;
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user