Skip to content

Commit 9091d32

Browse files
committed
Pre classes /cc #29
1 parent c20cac4 commit 9091d32

File tree

4 files changed

+74
-2
lines changed

4 files changed

+74
-2
lines changed

DOCUMENTATION.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,22 @@
22

33
You can see below the API reference of this module.
44

5+
### `showdownHighlight()`
6+
Highlight the code in the showdown input.
7+
8+
Examples:
9+
10+
```js
11+
let converter = new showdown.Converter({
12+
extensions: [showdownHighlight]
13+
});
14+
```
15+
16+
Enable the classes in the `<pre>` element:
17+
18+
```js
19+
let converter = new showdown.Converter({
20+
extensions: [showdownHighlight({ pre: true })]
21+
});
22+
```
23+

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ const showdown = require('showdown')
8181
// After requiring the module, use it as extension
8282
let converter = new showdown.Converter({
8383
// That's it
84-
extensions: [showdownHighlight]
84+
extensions: [showdownHighlight({
85+
// Whether to add the classes to the <pre> tag
86+
pre: true
87+
})]
8588
});
8689

8790
// Now you can Highlight code blocks
@@ -133,6 +136,30 @@ There are few ways to get help:
133136

134137

135138

139+
## :memo: Documentation
140+
141+
142+
### `showdownHighlight()`
143+
Highlight the code in the showdown input.
144+
145+
Examples:
146+
147+
```js
148+
let converter = new showdown.Converter({
149+
extensions: [showdownHighlight]
150+
});
151+
```
152+
153+
Enable the classes in the `<pre>` element:
154+
155+
```js
156+
let converter = new showdown.Converter({
157+
extensions: [showdownHighlight({ pre: true })]
158+
});
159+
```
160+
161+
162+
136163

137164

138165

example/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ const showdown = require('showdown')
77
// After requiring the module, use it as extension
88
let converter = new showdown.Converter({
99
// That's it
10-
extensions: [showdownHighlight]
10+
extensions: [showdownHighlight({
11+
// Whether to add the classes to the <pre> tag
12+
pre: true
13+
})]
1114
});
1215

1316
// Now you can Highlight code blocks

lib/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@ const decodeHtml = require("html-encoder-decoder").decode
66
, classAttr = 'class="'
77
;
88

9+
/**
10+
* showdownHighlight
11+
* Highlight the code in the showdown input.
12+
*
13+
* Examples:
14+
*
15+
* ```js
16+
* let converter = new showdown.Converter({
17+
* extensions: [showdownHighlight]
18+
* });
19+
* ```
20+
*
21+
* Enable the classes in the `<pre>` element:
22+
*
23+
* ```js
24+
* let converter = new showdown.Converter({
25+
* extensions: [showdownHighlight({ pre: true })]
26+
* });
27+
* ```
28+
*
29+
* @name showdownHighlight
30+
* @function
31+
*/
932
module.exports = function showdownHighlight({ pre = false }) {
1033
return [
1134
{

0 commit comments

Comments
 (0)