-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding extra styling, fixing unflattening code sample
- Loading branch information
1 parent
2e29098
commit 14bf592
Showing
4 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
$(document).ready(function () { | ||
var hlCode = document.querySelectorAll('pre code.cs'), | ||
i, | ||
hlLength = hlCode.length, | ||
mapperRegex = new RegExp('\\bMapper\\b', 'g'), | ||
typeRegex = new RegExp('(new</span>\\W+|class</span> <span class="hljs-title">|<)([A-Z][^&\\\( ]+)( |{|\\\(|>)', 'g'), | ||
genericTypeRegex = new RegExp('(IDictionary|Dictionary|IEnumerable|IReadOnlyCollection|Collection|List)<', 'g'), | ||
observer = new MutationObserver(function (mutations) { | ||
for (var mutation of mutations) { | ||
if (mutation.attributeName === 'class') { | ||
var innerHTML = mutation.target.innerHTML | ||
.replace(mapperRegex, '<span class="hljs-type">Mapper</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); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters