Exclude JS source code from the output

This commit is contained in:
Cotes Chung
2021-04-19 14:51:45 +08:00
parent 52f4012463
commit 72e8ffafa6
17 changed files with 24 additions and 23 deletions

View File

@@ -0,0 +1,20 @@
/**
* Add language indicator to code snippets
*/
$(function() {
const prefix = "language-";
const regex = new RegExp(`^${prefix}([a-z])+$`);
$(`div[class^=${prefix}`).each(function() {
let classes = $(this).attr("class").split(" ");
classes.forEach((_class) => {
if (regex.test(_class)) {
let lang = _class.substring(prefix.length);
$(this).attr("lang", `${lang}`);
}
});
});
});