mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-29 05:29:02 +00:00
Compare commits
5 Commits
4.0.0-alpha.6
...
4.x.x
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b81e94a5d | |||
| bc315a1dea | |||
| 7fc1e022ee | |||
| 78d947c5e8 | |||
| 9f9e1976e5 |
@@ -13,7 +13,7 @@
|
||||
<img src="https://badge.fury.io/js/gitbook.svg" />
|
||||
<a href="https://travis-ci.org/GitbookIO/gitbook"><img src="https://travis-ci.org/GitbookIO/gitbook.png?branch=master" /></a>
|
||||
<a href="https://ci.appveyor.com/project/GitBook/gitbook"><img src="https://ci.appveyor.com/api/projects/status/63nlflxcwmb2pue6?svg=true" /></a>
|
||||
<a href="https://ci.appveyor.com/project/GitBook/gitbook"><img src="https://slack.gitbook.com/badge.svg" /></a>
|
||||
<a href="https://slack.gitbook.com"><img src="https://slack.gitbook.com/badge.svg" /></a>
|
||||
</p>
|
||||
|
||||
GitBook is a command line tool (and Node.js library) for building beautiful books using GitHub/Git and Markdown (or AsciiDoc). Here is an example: [ReduxJS documentation](http://redux.js.org/).
|
||||
|
||||
+12
-1
@@ -158,6 +158,17 @@ You can create fenced code blocks by placing triple backticks ` ``` ` before and
|
||||
}
|
||||
```
|
||||
|
||||
If your code contains templating syntax such as `{{ this }}` (see [templating](/docs/templating/variables.md)), you can disable templating with a `raw` block:
|
||||
|
||||
{% raw %}
|
||||
{% raw %}
|
||||
```html
|
||||
<span>{{ this will not be interpreted as templating }}</span>
|
||||
```
|
||||
{% endraw %}
|
||||
{% endraw %}
|
||||
|
||||
|
||||
##### Syntax highlighting
|
||||
|
||||
You can add an optional language identifier to enable syntax highlighting in your fenced code block.
|
||||
@@ -216,7 +227,7 @@ Asterisks
|
||||
|
||||
### Ignoring Markdown formatting
|
||||
|
||||
You can tell GitBook to ignore (or escape) Markdown formatting by using `\` before the Markdown character.
|
||||
You can tell GitBook to ignore (escape) Markdown formatting by using `\` before the Markdown character.
|
||||
|
||||
```
|
||||
Let's rename \*our-new-project\* to \*our-old-project\*.
|
||||
|
||||
@@ -96,3 +96,6 @@ Languages are defined by `{ id: 'en', title: 'English' }`.
|
||||
| Variable | Description |
|
||||
| -------- | ----------- |
|
||||
| `glossary.path` | Path to the Glossary in the book |
|
||||
|
||||
### Limitations
|
||||
Variables won't expand when used inside `SUMMARY.md`.
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
const Summary = require('../../../models/summary');
|
||||
|
||||
describe('editArticleTitle', () => {
|
||||
const editArticleTitle = require('../editArticleTitle');
|
||||
const summary = Summary.createFromParts([
|
||||
{
|
||||
articles: [
|
||||
{
|
||||
title: 'My First Article',
|
||||
path: 'README.md'
|
||||
},
|
||||
{
|
||||
title: 'My Second Article',
|
||||
path: 'article.md'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Test'
|
||||
}
|
||||
]);
|
||||
|
||||
it('should correctly set title of first article', () => {
|
||||
const newSummary = editArticleTitle(summary, '1.1', 'Hello World');
|
||||
const article = newSummary.getByLevel('1.1');
|
||||
|
||||
expect(article.getTitle()).toBe('Hello World');
|
||||
});
|
||||
|
||||
it('should correctly set title of second article', () => {
|
||||
const newSummary = editArticleTitle(summary, '1.2', 'Hello World');
|
||||
const article = newSummary.getByLevel('1.2');
|
||||
|
||||
expect(article.getTitle()).toBe('Hello World');
|
||||
});
|
||||
});
|
||||
+9
-3
@@ -16,7 +16,7 @@ nodes:
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: hello.md
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: Hello
|
||||
@@ -26,5 +26,11 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: World
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: World
|
||||
|
||||
+14
-4
@@ -13,13 +13,23 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: Hello
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: 'hello.md'
|
||||
nodes:
|
||||
- kind: text
|
||||
text: 'Hello'
|
||||
- kind: block
|
||||
type: list_item
|
||||
nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: World
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: 'World'
|
||||
@@ -20,8 +20,13 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '1.1'
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '1.1'
|
||||
- kind: block
|
||||
type: unordered_list
|
||||
nodes:
|
||||
@@ -31,24 +36,39 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '1.1.1'
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '1.1.1'
|
||||
- kind: block
|
||||
type: list_item
|
||||
nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '1.1.2'
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '1.1.2'
|
||||
- kind: block
|
||||
type: list_item
|
||||
nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '1.2'
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '1.2'
|
||||
- kind: block
|
||||
type: unordered_list
|
||||
nodes:
|
||||
@@ -58,16 +78,26 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '1.2.1'
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '1.2.1'
|
||||
- kind: block
|
||||
type: list_item
|
||||
nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '1.2.2'
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '1.2.2'
|
||||
|
||||
- kind: block
|
||||
type: header_two
|
||||
@@ -84,8 +114,13 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '2.1'
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '2.1'
|
||||
- kind: block
|
||||
type: unordered_list
|
||||
nodes:
|
||||
@@ -95,8 +130,13 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '2.1.1'
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '2.1.1'
|
||||
- kind: block
|
||||
type: unordered_list
|
||||
nodes:
|
||||
@@ -106,8 +146,13 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '2.1.1.1'
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '2.1.1.1'
|
||||
- kind: block
|
||||
type: unordered_list
|
||||
nodes:
|
||||
@@ -117,5 +162,10 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '2.1.1.1.1'
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: '2.1.1.1.1'
|
||||
|
||||
@@ -13,13 +13,23 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ''
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ''
|
||||
- kind: block
|
||||
type: list_item
|
||||
nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ''
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ''
|
||||
|
||||
@@ -19,8 +19,13 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: 'Article 1'
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: 'Article 1'
|
||||
|
||||
- kind: block
|
||||
type: header_two
|
||||
@@ -48,8 +53,13 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: 'Article 2'
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: 'Article 2'
|
||||
|
||||
- kind: block
|
||||
type: header_two
|
||||
|
||||
@@ -13,8 +13,13 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: Hello
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: Hello
|
||||
|
||||
- kind: block
|
||||
type: header_two
|
||||
@@ -30,8 +35,13 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: World
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: World
|
||||
|
||||
- kind: block
|
||||
type: hr
|
||||
@@ -47,5 +57,10 @@ nodes:
|
||||
- kind: block
|
||||
type: unstyled
|
||||
nodes:
|
||||
- kind: text
|
||||
text: Yeah
|
||||
- kind: inline
|
||||
type: link
|
||||
data:
|
||||
href: ''
|
||||
nodes:
|
||||
- kind: text
|
||||
text: Yeah
|
||||
|
||||
@@ -21,7 +21,7 @@ function expectDocument(documentPath, parts) {
|
||||
|
||||
describe('summaryToDocument', () => {
|
||||
it('should convert unlinked articles', () => {
|
||||
expectDocument('ul.yaml', [
|
||||
expectDocument('article-no-link.yaml', [
|
||||
{
|
||||
title: '',
|
||||
articles: [
|
||||
@@ -39,7 +39,7 @@ describe('summaryToDocument', () => {
|
||||
});
|
||||
|
||||
it('should convert articles with links', () => {
|
||||
expectDocument('ul-with-link.yaml', [
|
||||
expectDocument('article-with-link.yaml', [
|
||||
{
|
||||
title: '',
|
||||
articles: [
|
||||
|
||||
@@ -8,24 +8,20 @@ const { BLOCKS, INLINES } = require('markup-it');
|
||||
*/
|
||||
function articleToBlock(article) {
|
||||
const { title, ref, articles } = article;
|
||||
const text = Text.createFromString(title);
|
||||
|
||||
// Text or link ?
|
||||
const innerNode = ref ? Inline.create({
|
||||
type: INLINES.LINK,
|
||||
nodes: [
|
||||
text
|
||||
],
|
||||
data: {
|
||||
href: ref
|
||||
}
|
||||
}) : text;
|
||||
|
||||
const nodes = [
|
||||
Block.create({
|
||||
type: BLOCKS.TEXT,
|
||||
nodes: [
|
||||
innerNode
|
||||
Inline.create({
|
||||
type: INLINES.LINK,
|
||||
nodes: [
|
||||
Text.createFromString(title)
|
||||
],
|
||||
data: {
|
||||
href: ref || ''
|
||||
}
|
||||
})
|
||||
]
|
||||
})
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user