@lucy/prism 1.4.1 → 1.6.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.
Files changed (3) hide show
  1. package/lib/lucy.js +21 -7
  2. package/package.json +11 -3
  3. package/readme.md +20 -0
package/lib/lucy.js CHANGED
@@ -1,7 +1,12 @@
1
1
  function addLucy(Prism) {
2
2
  Prism.languages.lucy = Prism.languages.extend('clike', {
3
3
  'class-name': [
4
- Prism.languages.clike['class-name']
4
+ Prism.languages.clike['class-name'],
5
+ // The type in `event name(Type)`.
6
+ {
7
+ pattern: /(\bevent\s+[a-zA-Z_]\w*\s*\(\s*)[a-zA-Z_]\w*(?=\s*\))/,
8
+ lookbehind: true
9
+ }
5
10
  ],
6
11
 
7
12
  'keyword': [
@@ -13,17 +18,21 @@ function addLucy(Prism) {
13
18
  pattern: /\b(?:use)\b/,
14
19
  lookbehind: true
15
20
  },
21
+ // `event name`, but not an event called event (`event => idle`).
22
+ {
23
+ pattern: /\bevent(?=\s+[a-zA-Z_])/
24
+ },
16
25
  {
17
26
  pattern: /\b(?:action|guard)\s+(?!\()\b/,
18
27
  lookbehind: true
19
28
  }
20
- ],
29
+ ]
30
+ });
31
+
32
+ Prism.languages.insertBefore('lucy', 'keyword', {
21
33
  'function': [
22
34
  {
23
- pattern: /\b(?:invoke)\b/
24
- },
25
- {
26
- pattern: /\b(?:assign|delay|guard|action|send|spawn|on)(?=\()\b/
35
+ pattern: /\b(?:action|assign|invoke|delay|guard|send|spawn|on)(?=\()\b/
27
36
  }
28
37
  ],
29
38
  'number': [
@@ -34,8 +43,13 @@ function addLucy(Prism) {
34
43
  'symbol': [
35
44
  {
36
45
  pattern: /(@(entry|exit))/
46
+ },
47
+ {
48
+ pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,
49
+ lookbehind: true
37
50
  }
38
- ]
51
+ ],
52
+ 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
39
53
  });
40
54
 
41
55
  Prism.languages.lucy['class-name'][0].pattern = /(\b(?:state)\s+)[\w.\\]+/;
package/package.json CHANGED
@@ -1,18 +1,26 @@
1
1
  {
2
2
  "name": "@lucy/prism",
3
- "version": "1.4.1",
3
+ "version": "1.6.0",
4
4
  "description": "Prism plugin for the Lucy language",
5
5
  "main": "lib/main.js",
6
6
  "files": [
7
7
  "lib"
8
8
  ],
9
9
  "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
10
+ "test": "node test/smoke.js"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/lucydsl/lucy-prism.git"
11
15
  },
12
16
  "keywords": [
13
17
  "Lucy",
14
18
  "Prism"
15
19
  ],
16
20
  "author": "Matthew Phillips",
17
- "license": "BSD-2-Clause"
21
+ "license": "BSD-2-Clause",
22
+ "bugs": {
23
+ "url": "https://github.com/lucydsl/lucy-prism/issues"
24
+ },
25
+ "homepage": "https://github.com/lucydsl/lucy-prism#readme"
18
26
  }
package/readme.md ADDED
@@ -0,0 +1,20 @@
1
+ # @lucy/prism
2
+
3
+ This is a Prism plugin for Lucy syntax highlighting.
4
+
5
+ ## Usage
6
+
7
+ This package exports a function that takes a `Prism` object. Typical usage looks like:
8
+
9
+ ```js
10
+ const Prism = require('prismjs');
11
+ const addLucy = require('@lucy/prism');
12
+
13
+ addLucy(Prism);
14
+
15
+ // Now use Prism as normal.
16
+ ```
17
+
18
+ ## License
19
+
20
+ BSD-2-Clause