Skip to content

Commit 9d2644a

Browse files
gdolleazu
authored andcommitted
fix: Check that ace plugin is loaded after include-codeblock (#41)
* rename and add new examples per template * Remove unrequired plugin Not required in fact. `gitbook-plugin-ace` is required only if user pass "ace" or "acefull" to the template option. It is specified in the README.md. * Update readme * Add check plugin load order - Add winston-color for color logs - produce a warning if gitbook-plugin-ace is not loaded (ace template won't work) - produce an error if gitbook-plugin-ace is loaded but before include-codeblock * update log message * update travis tests * Fix Readme * use path package * separate ace check
1 parent bc6b544 commit 9d2644a

34 files changed

+302
-11
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ language: node_js
33
node_js: "stable"
44
script:
55
- npm test
6-
- npm run test:example
6+
- npm run test:example-default
7+
- npm run test:example-ace
8+
- npm run test:example-custom

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ Templates let customize the rendered code. Several default templates are availab
5656
| --- | --- |
5757
| `default` | default template, standard markdown code style |
5858
| `full` | enable title, labeling, id, ... |
59-
| `ace` | enable ace code rendering |
60-
| `acefull` | enable ace code rendering with title, label, id, ... |
59+
| `ace` | enable ace code rendering (**ace plugin required**) |
60+
| `acefull` | enable ace code rendering with title, label, id, ... (**ace plugin required**) |
6161

62-
For more template, consult the list in [template/](templates/).
62+
- :information_source: For ace template, see [Ace section](#ace-plugin)
63+
- :information_source: For more template, consult the list in [template/](templates/).
6364

6465
Custom templates can be created to render the code by specifying a custom path
6566
to the template file.
@@ -81,7 +82,23 @@ Any contribution is welcome. Propose your new templates via pull-requests.
8182

8283
It is possible to use the gitbook ace plugin to have code numbering or custom themes
8384
(See [gitbook-ace-plugin](https://github.com/ymcatar/gitbook-plugin-ace) for more details).
84-
To use ace within include-codeblock, an "ace" template is required.
85+
To use ace within include-codeblock, you have to **load the ace plugin after include-codeblock!**
86+
and choose an ace temple (see [template/](templates/))
87+
88+
```js
89+
{
90+
"gitbook": "3.x.x",
91+
"plugins" : [
92+
"include-codeblock",
93+
"ace"
94+
]
95+
"pluginsConfig": {
96+
"include-codeblock": {
97+
"template": "ace", // or acefull
98+
}
99+
}
100+
}
101+
```
85102

86103
## Usage
87104

File renamed without changes.
File renamed without changes.

examples/ace/book.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const fs = require("fs");
2+
module.exports = {
3+
"gitbook": "3.x.x",
4+
"title": "gitbook-plugin-include-codeblock example-ace",
5+
"plugins": [
6+
"include-codeblock",
7+
"ace"
8+
],
9+
"pluginsConfig": {
10+
"include-codeblock": {
11+
"template": "ace"
12+
}
13+
}
14+
};
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "example",
2+
"name": "example-ace",
33
"version": "1.0.0",
44
"description": "gitbook-plugin-include-codeblock",
55
"private": true,
@@ -16,6 +16,6 @@
1616
"license": "MIT",
1717
"devDependencies": {
1818
"gitbook-cli": "^2.1.3",
19-
"gitbook-plugin-include-codeblock": "file:.."
19+
"gitbook-plugin-include-codeblock": "file:../../"
2020
}
2121
}

0 commit comments

Comments
 (0)