-
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy patht4-templating.js
More file actions
56 lines (55 loc) · 1.55 KB
/
t4-templating.js
File metadata and controls
56 lines (55 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// @ts-nocheck
/**
* @import {Refractor} from '../lib/core.js'
*/
t4Templating.displayName = 't4-templating'
t4Templating.aliases = []
/** @param {Refractor} Prism */
export default function t4Templating(Prism) {
;(function (Prism) {
function createBlock(prefix, inside, contentAlias) {
return {
pattern: RegExp('<#' + prefix + '[\\s\\S]*?#>'),
alias: 'block',
inside: {
delimiter: {
pattern: RegExp('^<#' + prefix + '|#>$'),
alias: 'important'
},
content: {
pattern: /[\s\S]+/,
inside: inside,
alias: contentAlias
}
}
}
}
function createT4(insideLang) {
var grammar = Prism.languages[insideLang]
var className = 'language-' + insideLang
return {
block: {
pattern: /<#[\s\S]+?#>/,
inside: {
directive: createBlock('@', {
'attr-value': {
pattern: /=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/,
inside: {
punctuation: /^=|^["']|["']$/
}
},
keyword: /\b\w+(?=\s)/,
'attr-name': /\b\w+/
}),
expression: createBlock('=', grammar, className),
'class-feature': createBlock('\\+', grammar, className),
standard: createBlock('', grammar, className)
}
}
}
}
Prism.languages['t4-templating'] = Object.defineProperty({}, 'createT4', {
value: createT4
})
})(Prism)
}