-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy patherb.js
37 lines (36 loc) · 1.05 KB
/
erb.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
// @ts-nocheck
import refractorMarkupTemplating from './markup-templating.js'
import refractorRuby from './ruby.js'
erb.displayName = 'erb'
erb.aliases = []
/** @type {import('../core.js').Syntax} */
export default function erb(Prism) {
Prism.register(refractorMarkupTemplating)
Prism.register(refractorRuby)
;(function (Prism) {
Prism.languages.erb = {
delimiter: {
pattern: /^(\s*)<%=?|%>(?=\s*$)/,
lookbehind: true,
alias: 'punctuation'
},
ruby: {
pattern: /\s*\S[\s\S]*/,
alias: 'language-ruby',
inside: Prism.languages.ruby
}
}
Prism.hooks.add('before-tokenize', function (env) {
var erbPattern =
/<%=?(?:[^\r\n]|[\r\n](?!=begin)|[\r\n]=begin\s(?:[^\r\n]|[\r\n](?!=end))*[\r\n]=end)+?%>/g
Prism.languages['markup-templating'].buildPlaceholders(
env,
'erb',
erbPattern
)
})
Prism.hooks.add('after-tokenize', function (env) {
Prism.languages['markup-templating'].tokenizePlaceholders(env, 'erb')
})
})(Prism)
}