mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-27 20:48:47 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 445c2327c4 | |||
| 7a33881b3b | |||
| 417ee789c4 | |||
| 22c118779c | |||
| 53dc206d71 | |||
| 3c9d8878df | |||
| 03cbe7b18f | |||
| 85f4c3be58 | |||
| eb09f61029 |
@@ -1,4 +1,91 @@
|
||||
gitbook
|
||||
GitBook
|
||||
=======
|
||||
|
||||
Library and command line utility for generating GitBooks
|
||||
GiBook is a command line tool (and Node.js library) for building beautiful programming books and exercises using GitHub/Git and Markdown. You can see an example: [Learn Javascript](http://gitbookio.github.io/javascript/).
|
||||
|
||||
## How to use it:
|
||||
|
||||
GitBook can be installed from **NPM** using:
|
||||
|
||||
```
|
||||
$ npm install gitbook -g
|
||||
```
|
||||
|
||||
You can serve a repository as a book using:
|
||||
|
||||
```
|
||||
$ gitbook serve ./repository
|
||||
```
|
||||
|
||||
Or simply build the static website using:
|
||||
|
||||
```
|
||||
$ gitbook build ./repository --output=./outputFolder
|
||||
```
|
||||
|
||||
Options for commands `build` and `serve` are:
|
||||
|
||||
```
|
||||
-t, --title <name> Name of the book to generate, defaults to repo name
|
||||
-i, --intro <intro> Description of the book to generate
|
||||
-g, --github <repo_path> ID of github repo like : username/repo
|
||||
```
|
||||
|
||||
## Book Format
|
||||
|
||||
A book is a GitHub repository containing at least 2 files: `README.md` and `SUMMARY.md`.
|
||||
|
||||
#### README.md
|
||||
|
||||
As usual, it should contains an introduction for your book. It will be automatically added to the final summary.
|
||||
|
||||
#### SUMMARY.md
|
||||
|
||||
The `SUMMARY.md` defines your book's structure. It should contain a list of chapters, linking to their respective pages.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
# Summary
|
||||
|
||||
This is the summary of my book.
|
||||
|
||||
* [section 1](section1/README.md)
|
||||
* [example 1](section1/example1.md)
|
||||
* [example 2](section1/example2.md)
|
||||
* [section 2](section2/README.md)
|
||||
* [example 1](section2/example1.md)
|
||||
```
|
||||
|
||||
Files that are not included in the `SUMMARY.md` will not be processed by `gitbook`.
|
||||
|
||||
#### Exercises
|
||||
|
||||
A book can contain interactive exercises (currently only in Javascript but Python and Ruby are coming soon ;) ). An exercise is a code challenge provided to the reader, which is given a code editor to write a solution which is checked against the book author's validation code.
|
||||
|
||||
An exercise is defined by 4 simple parts:
|
||||
|
||||
* Exercise **Message**/Goals (in markdown/text)
|
||||
* **Initial** code to show to the user, providing a starting point
|
||||
* **Solution** code, being a correct solution to the exercise
|
||||
* **Validation** code that tests the correctness of the user's input
|
||||
|
||||
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 =
|
||||
```
|
||||
|
||||
```js
|
||||
var x = 10;
|
||||
```
|
||||
|
||||
```js
|
||||
assert(x == 10);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
define([], function() {
|
||||
var isAvailable = function() {
|
||||
return (typeof mixpanel === "undefined");
|
||||
return (typeof mixpanel !== "undefined");
|
||||
};
|
||||
|
||||
var track = function(event, data) {
|
||||
if (!isAvailable()) return;
|
||||
if (!isAvailable()) {
|
||||
console.log("tracking not available!");
|
||||
return;
|
||||
}
|
||||
mixpanel.track(event, data);
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
+7
-2
@@ -1,12 +1,17 @@
|
||||
var _ = require('lodash');
|
||||
var marked = require('marked');
|
||||
var hljs = require('highlight.js');
|
||||
|
||||
var renderer = require('./renderer');
|
||||
|
||||
// Synchronous highlighting with highlight.js
|
||||
marked.setOptions({
|
||||
highlight: function (code) {
|
||||
return require('highlight.js').highlightAuto(code).value;
|
||||
highlight: function (code, lang) {
|
||||
try {
|
||||
return hljs.highlight(lang, code).value;
|
||||
} catch(e) {
|
||||
return hljs.highlightAuto(code).value;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.3",
|
||||
"description": "Library and cmd utility to generate GitBooks",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 157 KiB |
@@ -15,7 +15,7 @@
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<script type="text/javascript">
|
||||
(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" ");
|
||||
for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src=("https:"===e.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.2.min.js';f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
|
||||
for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.src=("https:"===e.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.2.min.js';f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
|
||||
mixpanel.init("01eb2b950ae09a5fdb15a98dcc5ff20e");
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user