Title / Description
Code /** * Add language indicator to code snippets */ // ace.config.set( // "basePath", // "https://cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-noconflict/" // ) $(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)) { const id = prefix+parseInt(Math.random()*100); let lang = _class.substring(prefix.length); $(this).attr("lang", `${lang}`); // $(this).css({"height": "500px", "width": "100%"}); // $(this).attr("id", id); // console.log(id); // ace.edit(id, { // theme: "ace/theme/dracula", // mode: `ace/mode/${lang}`, // autoScrollEditorIntoView: true, // readOnly: true // }); } }); }); });
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code