mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-29 13:39:11 +00:00
Compare commits
7 Commits
4.0.0-alpha.5
...
4.x.x
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b81e94a5d | |||
| bc315a1dea | |||
| 7fc1e022ee | |||
| 78d947c5e8 | |||
| 9f9e1976e5 | |||
| ef84a34fcd | |||
| 5df4c358a4 |
@@ -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`.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"lerna": "2.0.0-beta.31",
|
||||
"version": "4.0.0-alpha.5"
|
||||
"version": "4.0.0-alpha.6"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook-core",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"description": "Core for GitBook plugins API",
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"description": "Button to copy code blocks",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/plugin.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"dependencies": {
|
||||
"copy-to-clipboard": "^3.0.5",
|
||||
"gitbook-core": "^4.0.0-alpha.5"
|
||||
"gitbook-core": "^4.0.0-alpha.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"engines": {
|
||||
"gitbook": ">=3.0.0"
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"description": "Automatically add anchors to headings",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/plugin.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"dependencies": {
|
||||
"classnames": "^2.2.5",
|
||||
"gitbook-core": "^4.0.0-alpha.5"
|
||||
"gitbook-core": "^4.0.0-alpha.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"engines": {
|
||||
"gitbook": ">=3.0.0"
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"description": "Syntax highlighter for Gitbook",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/plugin.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"dependencies": {
|
||||
"gitbook-core": "^4.0.0-alpha.5",
|
||||
"gitbook-core": "^4.0.0-alpha.6",
|
||||
"highlight.js": "9.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"engines": {
|
||||
"gitbook": ">=3.0.0"
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"description": "Defines four types of styled hint blocks: info, danger, tip, working.",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/plugin.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"dependencies": {
|
||||
"classnames": "^2.2.5",
|
||||
"gitbook-core": "^4.0.0-alpha.5"
|
||||
"gitbook-core": "^4.0.0-alpha.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"engines": {
|
||||
"gitbook": ">=4.0.0"
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
"description": "Live reloading for your gitbook",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/plugin.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"engines": {
|
||||
"gitbook": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"gitbook-core": "^4.0.0-alpha.5"
|
||||
"gitbook-core": "^4.0.0-alpha.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"scripts": {
|
||||
"build-js": "gitbook-plugin build ./src/index.js ./_assets/plugin.js",
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
"description": "Static and local index for search in GitBook",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/theme.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"dependencies": {
|
||||
"gitbook-core": "^4.0.0-alpha.5",
|
||||
"gitbook-core": "^4.0.0-alpha.6",
|
||||
"html-entities": "1.2.0",
|
||||
"lunr": "0.5.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"engines": {
|
||||
"gitbook": ">=3.0.0"
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"description": "Search integration in GitBook",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/theme.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"dependencies": {
|
||||
"gitbook-core": "^4.0.0-alpha.5",
|
||||
"gitbook-core": "^4.0.0-alpha.6",
|
||||
"react": "^15.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin": "^4.0.0-alpha.6",
|
||||
"react-highlighter": "^0.3.3"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"description": "Sharing buttons in the toolbar",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/plugin.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"gitbook": {
|
||||
"properties": {
|
||||
"facebook": {
|
||||
@@ -53,10 +53,10 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"gitbook-core": "^4.0.0-alpha.5"
|
||||
"gitbook-core": "^4.0.0-alpha.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"engines": {
|
||||
"gitbook": ">=3.0.0"
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
"description": "Default theme for GitBook",
|
||||
"main": "./index.js",
|
||||
"browser": "./_assets/theme.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"engines": {
|
||||
"gitbook": ">=3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debounce": "^1.0.0",
|
||||
"gitbook-core": "^4.0.0-alpha.5"
|
||||
"gitbook-core": "^4.0.0-alpha.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"classnames": "^2.2.5",
|
||||
"font-awesome": "^4.6.3",
|
||||
"gitbook-markdown-css": "^1.0.1",
|
||||
"gitbook-plugin": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin": "^4.0.0-alpha.6",
|
||||
"less": "^2.7.1",
|
||||
"less-plugin-clean-css": "^1.5.1",
|
||||
"preboot": "git+https://github.com/mdo/preboot.git#4aab4edd85f076d50609cbe28e4fe66cc0771701"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook-plugin",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"description": "CLI for compiling and testing plugins",
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"homepage": "https://www.gitbook.com",
|
||||
"description": "Library and cmd utility to generate GitBooks",
|
||||
"main": "lib/index.js",
|
||||
@@ -22,16 +22,16 @@
|
||||
"extend": "^3.0.0",
|
||||
"fresh-require": "1.0.3",
|
||||
"front-matter": "^2.1.0",
|
||||
"gitbook-core": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-copy-code": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-headings": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-highlight": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-hints": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-livereload": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-lunr": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-search": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-sharing": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-theme-default": "^4.0.0-alpha.5",
|
||||
"gitbook-core": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-copy-code": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-headings": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-highlight": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-hints": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-livereload": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-lunr": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-search": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-sharing": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-theme-default": "^4.0.0-alpha.6",
|
||||
"github-slugid": "1.0.1",
|
||||
"graceful-fs": "4.1.4",
|
||||
"i18n-t": "1.0.1",
|
||||
|
||||
@@ -2,9 +2,7 @@ const { Record } = require('immutable');
|
||||
const File = require('./file');
|
||||
|
||||
const DEFAULTS = {
|
||||
file: new File(),
|
||||
title: String(),
|
||||
description: String()
|
||||
file: new File()
|
||||
};
|
||||
|
||||
class Readme extends Record(DEFAULTS) {
|
||||
@@ -12,14 +10,6 @@ class Readme extends Record(DEFAULTS) {
|
||||
return this.get('file');
|
||||
}
|
||||
|
||||
getTitle() {
|
||||
return this.get('title');
|
||||
}
|
||||
|
||||
getDescription() {
|
||||
return this.get('description');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set file linked to the readme.
|
||||
* @param {File} file
|
||||
@@ -32,7 +22,6 @@ class Readme extends Record(DEFAULTS) {
|
||||
/**
|
||||
* Create a new readme
|
||||
*
|
||||
* @param {File} file
|
||||
* @param {Object} def
|
||||
* @return {Readme}
|
||||
*/
|
||||
@@ -40,8 +29,7 @@ class Readme extends Record(DEFAULTS) {
|
||||
def = def || {};
|
||||
|
||||
return new Readme({
|
||||
title: def.title || '',
|
||||
description: def.description || ''
|
||||
file: def.file || ''
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 || ''
|
||||
}
|
||||
})
|
||||
]
|
||||
})
|
||||
];
|
||||
|
||||
@@ -16,8 +16,6 @@ describe('parseReadme', () => {
|
||||
const file = readme.getFile();
|
||||
|
||||
expect(file.exists()).toBeTruthy();
|
||||
expect(readme.title).toBe('Hello');
|
||||
expect(readme.description).toBe('And here is the description.');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
const expect = require('expect');
|
||||
const readDocument = require('./utils/readDocument');
|
||||
const readmeFromDocument = require('../readmeFromDocument');
|
||||
|
||||
function readReadme(filename) {
|
||||
const document = readDocument(filename);
|
||||
return readmeFromDocument(document);
|
||||
}
|
||||
|
||||
describe('readmeFromDocument', () => {
|
||||
|
||||
it('should parse only title', () => {
|
||||
const readme = readReadme('readme/only-title.yaml');
|
||||
expect(readme.title).toBe('Hello World');
|
||||
expect(readme.description).toBe('');
|
||||
});
|
||||
|
||||
it('should parse title and description', () => {
|
||||
const readme = readReadme('readme/normal.yaml');
|
||||
expect(readme.title).toBe('Hello World');
|
||||
expect(readme.description).toBe('This is a description');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
const lookupStructureFile = require('./lookupStructureFile');
|
||||
const readmeFromDocument = require('./readmeFromDocument');
|
||||
const Readme = require('../models/readme');
|
||||
const error = require('../utils/error');
|
||||
|
||||
/**
|
||||
@@ -10,7 +10,6 @@ const error = require('../utils/error');
|
||||
*/
|
||||
function parseReadme(book) {
|
||||
const { logger } = book;
|
||||
const fs = book.getContentFS();
|
||||
|
||||
return lookupStructureFile(book, 'readme')
|
||||
.then((file) => {
|
||||
@@ -19,12 +18,8 @@ function parseReadme(book) {
|
||||
}
|
||||
|
||||
logger.debug.ln(`readme found at ${file.path}`);
|
||||
return file.parse(fs)
|
||||
.then((document) => {
|
||||
let readme = readmeFromDocument(document);
|
||||
readme = readme.setFile(file);
|
||||
return book.set('readme', readme);
|
||||
});
|
||||
|
||||
return book.set('readme', Readme.create({ file }));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
const { BLOCKS } = require('markup-it');
|
||||
const Readme = require('../models/readme');
|
||||
|
||||
/**
|
||||
* Parse a readme from a document.
|
||||
* @param {Document} document
|
||||
* @return {Readme} readme
|
||||
*/
|
||||
function readmeFromDocument(document) {
|
||||
const { nodes } = document;
|
||||
|
||||
const first = nodes.first();
|
||||
const second = nodes.get(1);
|
||||
|
||||
return Readme.create({
|
||||
title: first && first.type == BLOCKS.HEADING_1 ? first.text : '',
|
||||
description: second && second.type == BLOCKS.PARAGRAPH ? second.text : ''
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = readmeFromDocument;
|
||||
Reference in New Issue
Block a user