highlightjs-daml 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 +209 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +250 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ABDK Consulting
|
|
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,209 @@
|
|
|
1
|
+
# highlightjs-daml
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/highlightjs-daml)
|
|
4
|
+
[](https://github.com/abdk-consulting/highlightjs-daml/actions/workflows/ci.yml)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
A [Highlight.js](https://highlightjs.org/) language plugin that adds rich
|
|
8
|
+
syntax highlighting for **[DAML](https://www.digitalasset.com/developers)** —
|
|
9
|
+
the smart contract language developed by Digital Asset for building
|
|
10
|
+
multi-party workflows on distributed ledgers.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- Full keyword coverage: `template`, `choice`, `interface`, `signatory`,
|
|
17
|
+
`observer`, `controller`, `with`, `where`, `do`, and all standard
|
|
18
|
+
Haskell-style keywords
|
|
19
|
+
- Template, interface, and exception declarations with class name highlighting
|
|
20
|
+
- Choice declarations highlighted as function titles
|
|
21
|
+
- Module and import directives highlighted as meta
|
|
22
|
+
- DAML/Haskell pragmas (`{-# OPTIONS_GHC … #-}`)
|
|
23
|
+
- Built-in types and functions: `Party`, `ContractId`, `Text`, `Decimal`,
|
|
24
|
+
`create`, `exercise`, `fetch`, `archive`, and more
|
|
25
|
+
- Literals: `True`, `False`, `None`, `Some`
|
|
26
|
+
- Haskell-style line (`--`) and block (`{- … -}`) comments
|
|
27
|
+
- Numeric literals with underscore separators (`1_000_000`)
|
|
28
|
+
- Haskell-style character literals (`'a'`, `'\n'`)
|
|
29
|
+
- Type names highlighted as `type`
|
|
30
|
+
- Infix operators in backticks (`` `elem` ``)
|
|
31
|
+
- Standard and Haskell-specific operators (`->`, `<-`, `=>`, `::`, `\`, …)
|
|
32
|
+
- Correct auto-detection: DAML templates reliably identified via `highlightAuto`
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install highlightjs-daml
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
> `highlight.js` ≥ 11 is a peer dependency — install it separately if you
|
|
43
|
+
> haven't already:
|
|
44
|
+
>
|
|
45
|
+
> ```bash
|
|
46
|
+
> npm install highlight.js
|
|
47
|
+
> ```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
### CommonJS / Node.js
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
const hljs = require("highlight.js");
|
|
57
|
+
const daml = require("highlightjs-daml");
|
|
58
|
+
|
|
59
|
+
hljs.registerLanguage("daml", daml.default ?? daml);
|
|
60
|
+
|
|
61
|
+
const code = `
|
|
62
|
+
template Iou
|
|
63
|
+
with
|
|
64
|
+
issuer : Party
|
|
65
|
+
owner : Party
|
|
66
|
+
amount : Decimal
|
|
67
|
+
where
|
|
68
|
+
signatory issuer
|
|
69
|
+
observer owner
|
|
70
|
+
|
|
71
|
+
choice Transfer : ContractId Iou
|
|
72
|
+
with newOwner : Party
|
|
73
|
+
controller owner
|
|
74
|
+
do
|
|
75
|
+
create this with owner = newOwner
|
|
76
|
+
`.trim();
|
|
77
|
+
|
|
78
|
+
const html = hljs.highlight(code, { language: "daml" }).value;
|
|
79
|
+
console.log(html);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### ES Modules
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
import hljs from "highlight.js";
|
|
86
|
+
import daml from "highlightjs-daml";
|
|
87
|
+
|
|
88
|
+
hljs.registerLanguage("daml", daml);
|
|
89
|
+
|
|
90
|
+
const result = hljs.highlight(code, { language: "daml" });
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Browser (CDN)
|
|
94
|
+
|
|
95
|
+
Load Highlight.js first, then load this plugin:
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.10.0/styles/github-dark.min.css">
|
|
99
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.10.0/highlight.min.js"></script>
|
|
100
|
+
<!-- highlightjs-daml -->
|
|
101
|
+
<script src="https://unpkg.com/highlightjs-daml/dist/index.js"></script>
|
|
102
|
+
<script>
|
|
103
|
+
hljs.registerLanguage("daml", window.hljsDaml?.default ?? window.hljsDaml);
|
|
104
|
+
hljs.highlightAll();
|
|
105
|
+
</script>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Then mark up your code blocks:
|
|
109
|
+
|
|
110
|
+
```html
|
|
111
|
+
<pre><code class="language-daml">
|
|
112
|
+
template Asset
|
|
113
|
+
with
|
|
114
|
+
issuer : Party
|
|
115
|
+
owner : Party
|
|
116
|
+
name : Text
|
|
117
|
+
where
|
|
118
|
+
signatory issuer
|
|
119
|
+
observer owner
|
|
120
|
+
|
|
121
|
+
choice Give : ContractId Asset
|
|
122
|
+
with newOwner : Party
|
|
123
|
+
controller owner
|
|
124
|
+
do create this with owner = newOwner
|
|
125
|
+
</code></pre>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Auto-detection
|
|
129
|
+
|
|
130
|
+
The plugin registers DAML with high-relevance rules on template/choice/signatory
|
|
131
|
+
constructs so `highlightAuto` correctly identifies DAML source files:
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
const result = hljs.highlightAuto(unknownCode);
|
|
135
|
+
console.log(result.language); // "daml"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Supported syntax elements
|
|
141
|
+
|
|
142
|
+
| Element | Highlight class |
|
|
143
|
+
|---------|----------------|
|
|
144
|
+
| `module`, `import` | `hljs-meta` |
|
|
145
|
+
| Pragmas `{-# … #-}` | `hljs-meta` |
|
|
146
|
+
| Keywords (`template`, `choice`, `signatory`, …) | `hljs-keyword` |
|
|
147
|
+
| Template / exception / data names | `hljs-title class_` |
|
|
148
|
+
| Choice names | `hljs-title function_` |
|
|
149
|
+
| Built-in types and functions | `hljs-built_in` |
|
|
150
|
+
| Type names (uppercase identifiers) | `hljs-type` |
|
|
151
|
+
| Literals (`True`, `False`, `None`, `Some`) | `hljs-literal` |
|
|
152
|
+
| String literals | `hljs-string` |
|
|
153
|
+
| Character literals | `hljs-string` |
|
|
154
|
+
| Numeric literals | `hljs-number` |
|
|
155
|
+
| Operators (`->`, `<-`, `::`, `=>`, …) | `hljs-operator` |
|
|
156
|
+
| Infix in backticks | `hljs-operator` |
|
|
157
|
+
| Comments (`--`, `{- … -}`) | `hljs-comment` |
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Example
|
|
162
|
+
|
|
163
|
+
```daml
|
|
164
|
+
module Finance where
|
|
165
|
+
|
|
166
|
+
import DA.List (sortOn)
|
|
167
|
+
|
|
168
|
+
template Iou
|
|
169
|
+
with
|
|
170
|
+
issuer : Party
|
|
171
|
+
owner : Party
|
|
172
|
+
amount : Decimal
|
|
173
|
+
currency : Text
|
|
174
|
+
where
|
|
175
|
+
signatory issuer
|
|
176
|
+
observer owner
|
|
177
|
+
|
|
178
|
+
ensure amount > 0.0
|
|
179
|
+
|
|
180
|
+
choice Transfer : ContractId Iou
|
|
181
|
+
with newOwner : Party
|
|
182
|
+
controller owner
|
|
183
|
+
do
|
|
184
|
+
create this with owner = newOwner
|
|
185
|
+
|
|
186
|
+
choice Settle : ()
|
|
187
|
+
controller owner
|
|
188
|
+
do
|
|
189
|
+
archive self
|
|
190
|
+
|
|
191
|
+
interface Token where
|
|
192
|
+
viewtype TokenView
|
|
193
|
+
getOwner : Party
|
|
194
|
+
getAmount : Decimal
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Compatibility
|
|
200
|
+
|
|
201
|
+
| highlight.js | highlightjs-daml |
|
|
202
|
+
|--------------|-----------------|
|
|
203
|
+
| ≥ 11.0.0 | ✓ |
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
[MIT](LICENSE) © ABDK Consulting
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,CAkRpD"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = daml;
|
|
4
|
+
function daml(hljs) {
|
|
5
|
+
// DAML uses Haskell-style line comments starting with --
|
|
6
|
+
const LINE_COMMENT = hljs.COMMENT('--', '$');
|
|
7
|
+
// DAML uses Haskell-style block comments {- ... -}
|
|
8
|
+
const BLOCK_COMMENT = hljs.COMMENT(/\{-/, /-\}/, { contains: ['self'] });
|
|
9
|
+
// Pragma / language extension: {-# OPTIONS_GHC ... #-}
|
|
10
|
+
const PRAGMA = {
|
|
11
|
+
className: 'meta',
|
|
12
|
+
begin: /\{-#/,
|
|
13
|
+
end: /#-\}/,
|
|
14
|
+
relevance: 10
|
|
15
|
+
};
|
|
16
|
+
// module ModuleName where
|
|
17
|
+
// import qualified DA.List as L hiding (sort)
|
|
18
|
+
const MODULE_IMPORT = {
|
|
19
|
+
className: 'meta',
|
|
20
|
+
begin: /^\s*(?:module|import)\b/,
|
|
21
|
+
end: /$/,
|
|
22
|
+
contains: [
|
|
23
|
+
LINE_COMMENT,
|
|
24
|
+
// qualified / as / hiding sub-keywords
|
|
25
|
+
{
|
|
26
|
+
className: 'keyword',
|
|
27
|
+
begin: /\b(?:qualified|as|hiding)\b/
|
|
28
|
+
},
|
|
29
|
+
// module/package name: starts with uppercase
|
|
30
|
+
{
|
|
31
|
+
className: 'title.class',
|
|
32
|
+
begin: /[A-Z][\w.]*/
|
|
33
|
+
},
|
|
34
|
+
// import hiding/explicit list (...)
|
|
35
|
+
{
|
|
36
|
+
begin: /\(/,
|
|
37
|
+
end: /\)/,
|
|
38
|
+
contains: [
|
|
39
|
+
{ className: 'title', begin: /[A-Za-z_]\w*/ }
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
// template TemplateName
|
|
45
|
+
const TEMPLATE_DEF = {
|
|
46
|
+
begin: /\btemplate\b/,
|
|
47
|
+
className: 'keyword',
|
|
48
|
+
relevance: 5,
|
|
49
|
+
starts: {
|
|
50
|
+
end: /(?=\bwith\b|\bwhere\b|\n\s*\n)/,
|
|
51
|
+
contains: [
|
|
52
|
+
{ className: 'title.class', begin: /[A-Z]\w*/, relevance: 0 }
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
// interface InterfaceName / interface instance I for T
|
|
57
|
+
const INTERFACE_DEF = {
|
|
58
|
+
begin: /\binterface\b/,
|
|
59
|
+
className: 'keyword',
|
|
60
|
+
starts: {
|
|
61
|
+
end: /(?=\bwith\b|\bwhere\b|\bfor\b|\n)/,
|
|
62
|
+
keywords: { keyword: 'instance for' },
|
|
63
|
+
contains: [
|
|
64
|
+
{ className: 'title.class', begin: /[A-Z]\w*/, relevance: 0 }
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
// choice [nonconsuming|preconsuming|postconsuming] ChoiceName
|
|
69
|
+
const CHOICE_DEF = {
|
|
70
|
+
begin: /\b(?:nonconsuming|preconsuming|postconsuming)?\s*choice\b/,
|
|
71
|
+
className: 'keyword',
|
|
72
|
+
starts: {
|
|
73
|
+
end: /(?=:|\bwith\b|\bcontroller\b)/,
|
|
74
|
+
contains: [
|
|
75
|
+
{ className: 'title.function', begin: /[A-Z]\w*/, relevance: 0 }
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
// exception ExceptionName
|
|
80
|
+
const EXCEPTION_DEF = {
|
|
81
|
+
begin: /\bexception\b/,
|
|
82
|
+
className: 'keyword',
|
|
83
|
+
starts: {
|
|
84
|
+
end: /(?=\bwith\b|\bwhere\b|\n)/,
|
|
85
|
+
contains: [
|
|
86
|
+
{ className: 'title.class', begin: /[A-Z]\w*/, relevance: 0 }
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
// data / newtype / type declarations
|
|
91
|
+
const DATA_DEF = {
|
|
92
|
+
begin: /\b(?:data|newtype|type)\b/,
|
|
93
|
+
className: 'keyword',
|
|
94
|
+
starts: {
|
|
95
|
+
end: /(?==|\bwhere\b|\bderiving\b|\n)/,
|
|
96
|
+
contains: [
|
|
97
|
+
{ className: 'title.class', begin: /[A-Z]\w*/, relevance: 0 },
|
|
98
|
+
// type variable (lowercase)
|
|
99
|
+
{ className: 'type', begin: /\b[a-z]\w*/, relevance: 0 }
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
// class / instance declarations
|
|
104
|
+
const CLASS_DEF = {
|
|
105
|
+
begin: /\b(?:class|instance)\b/,
|
|
106
|
+
className: 'keyword',
|
|
107
|
+
starts: {
|
|
108
|
+
end: /\bwhere\b/,
|
|
109
|
+
returnEnd: true,
|
|
110
|
+
contains: [
|
|
111
|
+
{ className: 'title.class', begin: /[A-Z]\w*/, relevance: 0 }
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
// Type annotations: anything starting with an uppercase letter is treated as a
|
|
116
|
+
// type name (Party, ContractId, Text, Optional, …). Low relevance so it
|
|
117
|
+
// doesn't interfere with constructor pattern use.
|
|
118
|
+
const TYPE_NAME = {
|
|
119
|
+
className: 'type',
|
|
120
|
+
begin: /\b[A-Z]\w*/,
|
|
121
|
+
relevance: 0
|
|
122
|
+
};
|
|
123
|
+
// Numeric literals:
|
|
124
|
+
// integer 42 -1 1_000_000
|
|
125
|
+
// decimal 3.14 1.0 -0.5
|
|
126
|
+
const NUMBER = {
|
|
127
|
+
className: 'number',
|
|
128
|
+
variants: [
|
|
129
|
+
// decimal / floating-point
|
|
130
|
+
{ begin: /\b\d[\d_]*\.\d[\d_]*(?:[eE][+-]?\d+)?\b/ },
|
|
131
|
+
// integer (including underscore separators)
|
|
132
|
+
{ begin: /\b\d[\d_]*\b/ }
|
|
133
|
+
],
|
|
134
|
+
relevance: 0
|
|
135
|
+
};
|
|
136
|
+
// Haskell-style character literals 'a' '\n' '\\'
|
|
137
|
+
const CHAR_LITERAL = {
|
|
138
|
+
className: 'string',
|
|
139
|
+
begin: /'/,
|
|
140
|
+
end: /'/,
|
|
141
|
+
contains: [{ begin: /\\[\s\S]/ }],
|
|
142
|
+
relevance: 0
|
|
143
|
+
};
|
|
144
|
+
// Infix operator in backticks `elem` `notElem`
|
|
145
|
+
const BACKTICK_INFIX = {
|
|
146
|
+
className: 'operator',
|
|
147
|
+
begin: /`[A-Za-z_]\w*`/,
|
|
148
|
+
relevance: 0
|
|
149
|
+
};
|
|
150
|
+
// Explicit rule for uppercase built-in identifiers so they are not
|
|
151
|
+
// shadowed by the generic TYPE_NAME rule that also matches [A-Z]\w*.
|
|
152
|
+
const BUILT_IN_TYPES = {
|
|
153
|
+
className: 'built_in',
|
|
154
|
+
begin: /\b(?:Int|Decimal|Numeric|BigNumeric|Text|Bool|Party|Date|Time|RelTime|ContractId|Optional|List|Map|Set|Enum|Update|Script|Scenario|Action)\b/,
|
|
155
|
+
relevance: 0
|
|
156
|
+
};
|
|
157
|
+
// Uppercase literals must also be caught before TYPE_NAME.
|
|
158
|
+
const LITERAL_NAMES = {
|
|
159
|
+
className: 'literal',
|
|
160
|
+
begin: /\b(?:True|False|None|Some)\b/,
|
|
161
|
+
relevance: 0
|
|
162
|
+
};
|
|
163
|
+
// DAML-specific template-clause keywords: these are highly distinctive and
|
|
164
|
+
// boost auto-detection relevance so `highlightAuto` identifies DAML reliably.
|
|
165
|
+
const DAML_CLAUSES = {
|
|
166
|
+
className: 'keyword',
|
|
167
|
+
begin: /\b(?:signatory|controller|maintainer|observer)\b/,
|
|
168
|
+
relevance: 3
|
|
169
|
+
};
|
|
170
|
+
// DAML / Haskell operators
|
|
171
|
+
const OPERATOR = {
|
|
172
|
+
className: 'operator',
|
|
173
|
+
begin: /->|<-|=>|::|\\|[+\-*/%&|^~!<>=?@#$:.]+/,
|
|
174
|
+
relevance: 0
|
|
175
|
+
};
|
|
176
|
+
return {
|
|
177
|
+
name: 'Daml',
|
|
178
|
+
aliases: ['daml'],
|
|
179
|
+
keywords: {
|
|
180
|
+
keyword:
|
|
181
|
+
// module system
|
|
182
|
+
'module import qualified as hiding ' +
|
|
183
|
+
// type declarations
|
|
184
|
+
'data newtype type class instance deriving where ' +
|
|
185
|
+
// template / choice / interface
|
|
186
|
+
'template choice interface viewtype requires implements ' +
|
|
187
|
+
'nonconsuming preconsuming postconsuming ' +
|
|
188
|
+
// template clauses
|
|
189
|
+
'with signatory observer controller ensure key maintainer ' +
|
|
190
|
+
'agreement ' +
|
|
191
|
+
// exceptions
|
|
192
|
+
'exception throw try catch ' +
|
|
193
|
+
// do-notation / control flow
|
|
194
|
+
'do let in if then else case of return ' +
|
|
195
|
+
// misc Haskell-style
|
|
196
|
+
'forall infixl infixr infix',
|
|
197
|
+
built_in:
|
|
198
|
+
// primitive types
|
|
199
|
+
'Int Decimal Numeric BigNumeric Text Bool Party Date Time RelTime ' +
|
|
200
|
+
// container / common types
|
|
201
|
+
'ContractId Optional List Map Set Enum ' +
|
|
202
|
+
// action types
|
|
203
|
+
'Update Script Scenario Action ' +
|
|
204
|
+
// Update primitives
|
|
205
|
+
'create exercise exerciseByKey fetch fetchByKey lookupByKey ' +
|
|
206
|
+
'visibleByKey archive abort assert getTime ' +
|
|
207
|
+
// Script primitives
|
|
208
|
+
'submit submitMustFail allocateParty getParty ' +
|
|
209
|
+
'passTime passToDate ' +
|
|
210
|
+
// common stdlib
|
|
211
|
+
'show error debug trace not and or',
|
|
212
|
+
literal: 'True False None Some'
|
|
213
|
+
},
|
|
214
|
+
contains: [
|
|
215
|
+
// ── comments ──────────────────────────────────────────────────────────
|
|
216
|
+
LINE_COMMENT,
|
|
217
|
+
// PRAGMA must precede BLOCK_COMMENT: both start with {- but {-# is more specific
|
|
218
|
+
PRAGMA,
|
|
219
|
+
BLOCK_COMMENT,
|
|
220
|
+
// ── module / import directives ─────────────────────────────────────────
|
|
221
|
+
MODULE_IMPORT,
|
|
222
|
+
// ── string literals ───────────────────────────────────────────────────
|
|
223
|
+
hljs.QUOTE_STRING_MODE,
|
|
224
|
+
// ── character literals ───────────────────────────────────────────────
|
|
225
|
+
CHAR_LITERAL,
|
|
226
|
+
// ── numeric literals ─────────────────────────────────────────────────
|
|
227
|
+
NUMBER,
|
|
228
|
+
// ── declaration openers (give high relevance for auto-detect) ─────────
|
|
229
|
+
TEMPLATE_DEF,
|
|
230
|
+
INTERFACE_DEF,
|
|
231
|
+
CHOICE_DEF,
|
|
232
|
+
EXCEPTION_DEF,
|
|
233
|
+
DATA_DEF,
|
|
234
|
+
CLASS_DEF,
|
|
235
|
+
// ── infix in backticks ────────────────────────────────────────────────
|
|
236
|
+
BACKTICK_INFIX,
|
|
237
|
+
// ── operators ────────────────────────────────────────────────────────
|
|
238
|
+
OPERATOR,
|
|
239
|
+
// ── uppercase built-in identifiers (before generic TYPE_NAME) ────────
|
|
240
|
+
BUILT_IN_TYPES,
|
|
241
|
+
// ── uppercase literals (before generic TYPE_NAME) ─────────────────────
|
|
242
|
+
LITERAL_NAMES,
|
|
243
|
+
// ── DAML-specific clause keywords (high relevance for auto-detect) ─────
|
|
244
|
+
DAML_CLAUSES,
|
|
245
|
+
// ── type names ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
246
|
+
TYPE_NAME
|
|
247
|
+
]
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources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,cAAc;YAEd,yEAAyE;YACzE,aAAa;YAEb,0EAA0E;YAC1E,YAAY;YAEZ,gJAAgJ;YAChJ,SAAS;SACV;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "highlightjs-daml",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Highlight.js syntax definition for the DAML language",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/index.js",
|
|
9
|
+
"dist/index.js.map",
|
|
10
|
+
"dist/index.d.ts",
|
|
11
|
+
"dist/index.d.ts.map",
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc --project tsconfig.json",
|
|
17
|
+
"build:watch": "tsc --project tsconfig.json --watch",
|
|
18
|
+
"test": "npm run build && node --test dist/test/index.test.js",
|
|
19
|
+
"lint": "tsc --project tsconfig.json --noEmit",
|
|
20
|
+
"prepublishOnly": "npm run build && npm test",
|
|
21
|
+
"clean": "rm -rf dist"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"highlightjs",
|
|
25
|
+
"highlight.js",
|
|
26
|
+
"daml",
|
|
27
|
+
"syntax-highlighting",
|
|
28
|
+
"smart-contracts",
|
|
29
|
+
"digital-asset",
|
|
30
|
+
"functional-programming"
|
|
31
|
+
],
|
|
32
|
+
"author": "ABDK Consulting",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/abdk-consulting/highlightjs-daml.git"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/abdk-consulting/highlightjs-daml/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/abdk-consulting/highlightjs-daml#readme",
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"highlight.js": ">=11.9.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "20.0.0",
|
|
47
|
+
"highlight.js": "^11.11.1",
|
|
48
|
+
"typescript": "6.0.2"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=18.0.0"
|
|
52
|
+
}
|
|
53
|
+
}
|