Skip to content

Commit a3000f2

Browse files
author
Christopher Baker
authored
colors (#15)
* add prism (fixes #14) * add line number, previewers, and command line * adjust styles
1 parent 04083af commit a3000f2

File tree

9 files changed

+125
-460
lines changed

9 files changed

+125
-460
lines changed

CONTRIBUTING.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ For general contributing guidelines, see the [Contributing Guide on DoneJS.com](
66

77
bit-docs-prettify
88
├── bit-docs.js # Registers this package into the bit-docs system as a dependency.
9-
├── prettify-engine.js # The minified JavaScript for the prettify engine from google/code-prettify.
10-
├── prettify.js # Bootstraps the prettify-engine.js and prettify.less files.
11-
├── prettify.less # The "Tomorrow Night" syntax highlight theme.
9+
├── prettify.js # Bootstraps prism.
1210
└── test.js # Creates temp/index.html with <pre><code>var str ='hello world';</code></pre>
1311
# to verify that prettyprint gets applied after a timeout.
1412

@@ -35,16 +33,32 @@ npm test
3533
This will produce a directory and file at `temp/index.html`, containing the source-code snippet in HTML:
3634

3735
```html
38-
<pre><code>var str ='hello world';</code></pre>
36+
<pre><code class="language-javascript">var str = 'hello world';</code></pre>
37+
<pre><code class="language-css">body{ margin: 0; background: purple; }</code></pre>
38+
<pre><code>// some misc code</code></pre>
39+
<p><code>var str = 'hello world';</code>
3940
```
4041

4142
Running the tests will verify that this source-code snippet in HTML is correctly prettified by the plugin.
4243

4344
In [`test.js`](test.js), the [bit-docs-generate-html](https://github.com/bit-docs/bit-docs-generate-html) plugin is generating HTML from the equivalent of this markdown:
4445

46+
```javascript
47+
var str = 'hello world';
4548
```
46-
var str ='hello world';
49+
50+
```css
51+
body {
52+
margin: 0;
53+
background: purple;
54+
}
55+
```
56+
4757
```
58+
// some misc code
59+
```
60+
61+
`var str = 'hello world';`
4862

4963
That shows how a bit-docs "generator" plugin can generate the right HTML to play nice with `bit-docs-prettify`.
5064

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,15 @@ Now use the `bit-docs` command-line tool to install the added plugin dependency:
3131

3232
Your project should now support syntax highlighting of source-code snippets in the following languages:
3333

34-
bsh, c, cc, cpp, cs, csh, cyc, cv, htm, html, java, js, m, mxml, perl, pl, pm, py, rb, sh, xhtml, xml, xsl
34+
javascript, js, clike, css, markup, xml, html, mathml, svg
3535

3636
Use the following HTML code to trigger syntax highlighting of a source-code snippet:
3737

3838
```html
39-
<pre><code class="language-java">...</code></pre>
39+
<pre><code class="language-javascript">...</code></pre>
4040
```
4141

42-
You can replace `language-java` with an option from the list of supported languages above, like `language-js`.
43-
44-
The code prettifier script will make an educated guess if you remove the `class="language-*"` declaration entirely.
42+
You can replace `language-javascript` with an option from the list of supported languages above, like `language-js`.
4543

4644
## Contributing
4745

bit-docs.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@
44
* @group bit-docs-prettify/static static
55
*
66
* @description A bit-docs plugin that makes source-code snippets in HTML prettier.
7-
*
7+
*
88
* @body
9-
*
9+
*
1010
* This plugin registers onto the `html` hook.
11-
*
11+
*
1212
* Registering the `html` hook adds a static JavaScript file
1313
* [bit-docs-prettify/prettify.js] that will go through every `<code>` element
14-
* on the page applying the
15-
* [code prettifier](https://github.com/google/code-prettify).
14+
* on the page applying
15+
* [prism](https://www.npmjs.com/package/prismjs).
1616
*/
17-
module.exports = function(bitDocs){
18-
var pkg = require("./package.json");
19-
var dependencies = {};
20-
dependencies[pkg.name] = pkg.version;
17+
module.exports = function(bitDocs) {
18+
var pkg = require("./package.json");
19+
20+
var dependencies = {};
21+
dependencies[pkg.name] = pkg.version;
2122

22-
bitDocs.register("html", {
23-
dependencies: dependencies
24-
});
23+
bitDocs.register("html", {
24+
dependencies: dependencies
25+
});
2526
}

package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@
2525
"url": "https://github.com/bit-docs/bit-docs-prettify/issues"
2626
},
2727
"homepage": "https://github.com/bit-docs/bit-docs-prettify#readme",
28-
"system": {
29-
"meta": {
30-
"./prettify-engine": {
31-
"format": "global"
32-
}
33-
}
34-
},
3528
"devDependencies": {
3629
"bit-docs-generate-html": "^0.1.0",
3730
"connect": "^2.14.4",
3831
"mocha": "^3.1.2",
3932
"q": "^1.4.1",
4033
"zombie": "^4.2.1"
34+
},
35+
"dependencies": {
36+
"prismjs": "^1.11.0"
4137
}
4238
}

prettify-engine.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

prettify-variables.less

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)