stagit-custom

personal fork of stagit
git clone https://git.nindwen.blue/stagit-custom.git
Files | Log | Refs | LICENSE

script.js (587B)



function replaceCumulative(str, find, replace) {
  for (var i = 0; i < find.length; i++)
    str = str.replace(new RegExp(find[i],"g"), replace[i]);
  return str;
};

const extensions = [
  "rs",
  "md",
  "py",
  "rb",
  "sh",
];
const names = [
  "rust",
  "markdown",
  "python",
  "ruby",
  "bash",
];

Prism.hooks.add('before-highlightall', function (env) {
  const elem = document.getElementsByTagName('code')[0];
  if (elem) {
    let lang = elem.className.split('-').pop();
    lang = replaceCumulative(lang, extensions, names);
    elem.className = "language-" + lang;
  }
});