web/assets/js/_utils/lang-badge.js

21 lines
435 B
JavaScript
Raw Normal View History

/**
* Add language indicator to code snippets
*/
$(function() {
const prefix = "language-";
const regex = new RegExp(`^${prefix}([a-z])+$`);
$(`div[class^=${prefix}`).each(function() {
2021-01-23 10:07:18 +03:00
let classes = $(this).attr("class").split(" ");
2021-01-23 10:07:18 +03:00
classes.forEach((_class) => {
if (regex.test(_class)) {
let lang = _class.substring(prefix.length);
$(this).attr("lang", `${lang}`);
}
});
});
});