highlightjs-jai 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +121 -0
- package/dist/jai.cjs +29060 -0
- package/dist/jai.es.js +29058 -0
- package/dist/jai.es.min.js +2 -0
- package/dist/jai.js +29064 -0
- package/dist/jai.min.js +2 -0
- package/dist/package.json +3 -0
- package/dist/styles/jaiEverything.css +2147 -0
- package/package.json +77 -0
- package/src/languages/jai.js +29035 -0
- package/src/styles/jaiEverything.css +2147 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 GufNZ
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# highlightjs-jai
|
|
2
|
+
|
|
3
|
+
Jai language definition for `highlight.js`, as used in Discord etc.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Install the package alongside Highlight.js:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install highlight.js highlightjs-jai
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Static website or simple usage
|
|
14
|
+
|
|
15
|
+
Load the browser bundle after Highlight.js.
|
|
16
|
+
The bundle registers Jai automatically.
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<script type="text/javascript" src="/path/to/highlight.min.js"></script>
|
|
20
|
+
<script type="text/javascript" charset="UTF-8" src="/path/to/highlightjs-jai/dist/jai.min.js"></script>
|
|
21
|
+
<script type="text/javascript">
|
|
22
|
+
hljs.highlightAll();
|
|
23
|
+
</script>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Using directly from the UNPKG CDN
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
<script type="text/javascript" src="https://unpkg.com/highlightjs-jai/dist/jai.min.js"></script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- More info: <https://unpkg.com>
|
|
33
|
+
|
|
34
|
+
### With Node or another build system
|
|
35
|
+
|
|
36
|
+
CommonJS:
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
const hljs = require('highlight.js');
|
|
40
|
+
const jai = require('highlightjs-jai');
|
|
41
|
+
|
|
42
|
+
hljs.registerLanguage('jai', jai);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
ES modules:
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
import hljs from 'highlight.js';
|
|
49
|
+
import jai from 'highlightjs-jai';
|
|
50
|
+
|
|
51
|
+
hljs.registerLanguage('jai', jai);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### React
|
|
55
|
+
|
|
56
|
+
You need to import both Highlight.js and the third-party language like Jai:
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
import React, { Component } from 'react'
|
|
60
|
+
import hljs from 'highlight.js'
|
|
61
|
+
|
|
62
|
+
import 'highlight.js/scss/darcula.scss' // Your favourite theme.
|
|
63
|
+
|
|
64
|
+
import jai from 'highlightjs-jai'
|
|
65
|
+
|
|
66
|
+
hljs.registerLanguage('jai', jai);
|
|
67
|
+
|
|
68
|
+
class Highlighter extends Component {
|
|
69
|
+
constructor(props) {
|
|
70
|
+
super(props);
|
|
71
|
+
hljs.highlightAll();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
render() {
|
|
75
|
+
const { children } = this.props;
|
|
76
|
+
return (
|
|
77
|
+
<pre ref={(node) => this.node = node}>
|
|
78
|
+
<code className="jai">
|
|
79
|
+
{children}
|
|
80
|
+
</code>
|
|
81
|
+
</pre>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default Highlighter;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Theme
|
|
90
|
+
|
|
91
|
+
An example theme is included.
|
|
92
|
+
It is mostly designed for testing the matching, but it uses separate structural CSS and configuration variables.
|
|
93
|
+
To make a custom Jai theme, copy [jaiEverything.css](dist/styles/jaiEverything.css) and alter the variables at the top.
|
|
94
|
+
You only need to set the variables you want to override; the structural rules provide fallbacks.
|
|
95
|
+
|
|
96
|
+
With a bundler, the theme can also be imported from the package:
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
import 'highlightjs-jai/styles/jaiEverything.css';
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
See also the [css-class-reference](css-class-reference.md).
|
|
103
|
+
|
|
104
|
+
## Known Limitations
|
|
105
|
+
There are a few spots where we currently don't differentiate between line comments and block comments.
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
This grammar is released under the MIT License.
|
|
110
|
+
See [LICENSE][1] file for details.
|
|
111
|
+
|
|
112
|
+
### Author & Maintainer
|
|
113
|
+
|
|
114
|
+
J.Chris Findlay <j.chris.findlay@gmail.com>
|
|
115
|
+
|
|
116
|
+
## Links
|
|
117
|
+
|
|
118
|
+
- The official site for the Highlight.js library is <https://highlightjs.org/>.
|
|
119
|
+
- The Highlight.js GitHub project: <https://github.com/highlightjs/highlight.js>.
|
|
120
|
+
|
|
121
|
+
[1]: https://github.com/highlightjs/highlightjs-jai/blob/main/LICENSE
|