-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #24: Compatibility with Gitbook 2.x.x
- Loading branch information
Rob McGuinness
committed
Jul 9, 2017
1 parent
1f71cde
commit e3d28ef
Showing
3 changed files
with
39 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,41 @@ | ||
var tester = require('gitbook-tester'); | ||
var test = require('tape'); | ||
|
||
var pkg = require('./package.json'); | ||
|
||
test('highlight javascript code block', function (t) { | ||
|
||
t.plan(1); | ||
function expect(t, version, content, expected) { | ||
|
||
tester.builder() | ||
.withContent('```js\nfunction() { return true };\n```') | ||
.withContent(content) | ||
.withLocalPlugin(__dirname) | ||
.withBookJson({ | ||
gitbook: pkg.engines.gitbook, | ||
gitbook: version, | ||
plugins: ['prism', '-highlight'] | ||
}) | ||
.create() | ||
.then(function(result) { | ||
var expected = '<pre class="language-"><code class="lang-js"><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token boolean">true</span> <span class="token punctuation">}</span><span class="token punctuation">;</span></code></pre>'; | ||
t.equal(result[0].content, expected); | ||
t.equal(result[0].content, expected, 'gitbook version ' + version); | ||
}) | ||
.done(); | ||
|
||
} | ||
|
||
test('highlight javascript code block', function (t) { | ||
|
||
t.plan(2); | ||
|
||
var content = '```js\nfunction() { return true };\n```'; | ||
var expected = '<pre class="language-"><code class="lang-js"><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token boolean">true</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>\n</code></pre>'; | ||
expect(t, '>=2.4.1', content, expected); | ||
expect(t, '>=3.0.0', content, expected); | ||
|
||
}); | ||
|
||
test('highlight csharp code using shortcut', function (t) { | ||
|
||
t.plan(1); | ||
t.plan(2); | ||
|
||
tester.builder() | ||
.withContent('```cs\nusing System; class Program {public static void Main(string[] args) {Console.WriteLine("Hello, world!"); } }\n```') | ||
.withLocalPlugin(__dirname) | ||
.withBookJson({ | ||
gitbook: pkg.engines.gitbook, | ||
plugins: ['prism', '-highlight'] | ||
}) | ||
.create() | ||
.then(function(result) { | ||
var expected = '<pre class="language-"><code class="lang-cs"><span class="token keyword">using</span> System<span class="token punctuation">;</span> <span class="token keyword">class</span> <span class="token class-name">Program</span> <span class="token punctuation">{</span><span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">Main</span><span class="token punctuation">(</span><span class="token keyword">string</span><span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token punctuation">{</span>Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span><span class="token string">"Hello, world!"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span></code></pre>'; | ||
t.equal(result[0].content, expected); | ||
}) | ||
.done(); | ||
var content = '```cs\nusing System; class Program {public static void Main(string[] args) {Console.WriteLine("Hello, world!"); } }\n```'; | ||
var expected = '<pre class="language-"><code class="lang-cs"><span class="token keyword">using</span> System<span class="token punctuation">;</span> <span class="token keyword">class</span> <span class="token class-name">Program</span> <span class="token punctuation">{</span><span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">Main</span><span class="token punctuation">(</span><span class="token keyword">string</span><span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token punctuation">{</span>Console<span class="token punctuation">.</span><span class="token function">WriteLine</span><span class="token punctuation">(</span><span class="token string">"Hello, world!"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span>\n</code></pre>'; | ||
expect(t, '>=2.4.1', content, expected); | ||
expect(t, '>=3.0.0', content, expected); | ||
|
||
}); |