arcnyxx.net.git
colour.js
$(document).ready(function() {
$('code.c').each(function() {
this.innerHTML =
this.innerHTML.replace(/(".*?"|'.'|\b[0-9]+?\b|\btrue\b|\bfalse\b|\bNULL\b|\bsizeof\b)/g, "<span style='color: var(--l);'>$&</span>")
.replace(/\b(break|case|continue|default|do|else|for|goto|if|return|switch|while)\b/g, "<span style='color: var(--k);'>$&</span>")
.replace(/\b(auto|bool|char|const|double|enum|extern|float|inline|int|long|register|restrict|short|signed|static|struct|typedef|union|unsigned|void|volatile|\w+?_t)\b/g, "<span style='color: var(--t);'>$&</span>")
.replace(/\/\*(.|\n)*?\*\//gm, "<span style='color: var(--n);'>$&</span>")
.replace(/\/\/.*$/gm, "<span style='color: var(--n);'>$&</span>")
.replace(/(#if|#elif|#ifdef|#ifndef|#define|#undef|#line|#error|#pragma)(\\\n|.)*\n/g, "<span style='color: var(--p);'>$&</span>")
.replace(/#include\b.*?\b/g, "<span style='color: var(--p);'>$&</span>")
.replace(/(#else|#endif)\b/g, "<span style='color: var(--p);'>$&</span>");
});
$('code > span').find('span').contents().unwrap();
});