-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathao-docs.js
25 lines (24 loc) · 1.27 KB
/
ao-docs.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
$(function () {
var hlCode = document.querySelectorAll('pre code.language-cs,pre code.cs'),
hlLength = hlCode.length,
i, l,
termsRegex = new RegExp('\\b(' + (window['dox-cls'] || 'xyz') + ')\\b', 'g'),
typeRegex = /(new<\/span>\W+|class<\/span> <span class="hljs-title">|public<\/span>\W+|: <span class="hljs-title">|<)([A-Z][^& \(\[\]]+)( |{|\(|\[\]>|>)/g,
genericTypeRegex = /(I{0,1}Dictionary|IEnumerable|IReadOnlyCollection|I{0,1}Collection|I{0,1}List)</g,
observer = new MutationObserver(function (mutations) {
for (i = 0, l = mutations.length; i < l; ++i) {
var mutation = mutations[i];
if (mutation.attributeName === 'class') {
var innerHtml = mutation.target.innerHTML
.replace(termsRegex, '<span class="hljs-type">$1</span>')
.replace(typeRegex, '$1<span class="hljs-type">$2</span>$3')
.replace(genericTypeRegex, '<span class="hljs-type">$1</span><');
mutation.target.innerHTML = innerHtml;
}
}
}),
config = { attributes: true };
for (i = 0; i < hlLength; ++i) {
observer.observe(hlCode[i], config);
}
});