-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy patht4-templating.js
53 lines (52 loc) · 1.51 KB
/
t4-templating.js
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
// @ts-nocheck
t4Templating.displayName = 't4-templating'
t4Templating.aliases = []
/** @type {import('../core.js').Syntax} */
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)
}