You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+56-9
Original file line number
Diff line number
Diff line change
@@ -10,17 +10,17 @@ The below screenshot was captured from a [demo webpage](demo/testcode.html) afte
10
10
11
11
## Usage
12
12
13
-
Simply include the Highlight.js library in your webpage, then load this module.
13
+
Simply include the Highlight.js library in your webpage or Node app, then load this module.
14
14
15
15
### Static website or simple usage
16
16
17
17
Simply load this module after loading Highlight.js. You'll use the minified version found in the `dist` directory. This module is just a CDN build of the language, so it will register itself as the Javascript is loaded.
If you're using Node / Webpack / Rollup / Browserify, etc, simply require the language module, then register it with Highlight.js.
44
53
45
54
```javascript
46
-
var hljs =require('highlight.js');
47
-
varhljsApexTxt=require('highlightjs-apex');
55
+
var hljs =require('highlightjs');
56
+
varhljsApex=require('highlightjs-apex');
48
57
49
-
hljs.registerLanguage('apex', hljsApexTxt);
58
+
hljs.registerLanguage('apex', hljsApex);
50
59
hljs.highlightAll();
51
60
```
52
61
62
+
63
+
### React
64
+
65
+
You need to import both Highlight.js and third-party language like Apex:
66
+
67
+
```js
68
+
importReact, {Component} from'react'
69
+
import'highlight.js/scss/vs.scss' # your favourite theme
70
+
importapexfrom'./apex'
71
+
importhljsfrom'highlight.js'
72
+
hljs.registerLanguage('apex', apex);
73
+
74
+
classHighlighterextendsComponent
75
+
{
76
+
constructor(props)
77
+
{
78
+
super(props);
79
+
hljs.highlightAll();
80
+
}
81
+
82
+
render()
83
+
{
84
+
let {children} =this.props;
85
+
return
86
+
{
87
+
<pre ref={(node) =>this.node= node}>
88
+
<code className="language-apex">
89
+
{children}
90
+
</code>
91
+
</pre>
92
+
}
93
+
}
94
+
}
95
+
96
+
exportdefaultHighlighter;
97
+
```
98
+
53
99
## License
54
100
55
-
Highlight.js is released under the BSD 3-Clause License. See [LICENSE](/LICENSE) file for details.
101
+
Highlight.js is released under the BSD 3-Clause License. See [LICENSE](https://github.com/highlightjs/highlight.js/blob/main/LICENSE) file for details.
102
+
Highlightjs-apex is released under the MIT License. See [LICENSE](/LICENSE.md) file for details.
0 commit comments