| Server IP : 127.0.1.1 / Your IP : 216.73.216.152 Web Server : Apache/2.4.52 (Ubuntu) System : Linux bahcrestlinepropertiesllc 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/bahcrestline/core/vendor/scrivo/highlight.php/tools/ |
Upload File : |
"use strict";
require(["dojo/node!fs", "dojox/json/ref", "dojo/_base/kernel"], function(fs, ref, kernel) {
const nodeRequire = kernel.global.require && kernel.global.require.nodeRequire;
const HIGHLIGHT_DIR = dojo.config.highlightJsDir;
const CWD = dojo.config.cwd;
const LANGS_W_DEPS = ['arduino.js'];
const cloneDeep = nodeRequire(`${CWD}/lodash.cloneDeep.js`);
const hljs = nodeRequire(`${HIGHLIGHT_DIR}/highlight.js`);
/**
* Translate any RegExp objects that may exist in a language definition into a string representation.
*
* @param {Object} lang
* @param {number} nestingLevel
*/
function regexToStr(lang, nestingLevel = 0) {
// Max recursion level
if (nestingLevel > 15) {
return;
}
for (const key in lang) {
if (lang[key] instanceof RegExp) {
lang[key] = lang[key].source;
} else if (typeof lang[key] === 'object') {
regexToStr(lang[key], nestingLevel + 1);
}
}
}
/**
* PCRE does not support the `\uXXXX` syntax, so we must use `\x{XXXX}` instead.
*
* @param {string} s
*
* @see https://www.regular-expressions.info/unicode.html#codepoint
*
* @returns {string}
*/
function jsUnicodeToPhpUnicode(s) {
return s.replace(/\\u([0-9A-Fa-f]+)/g, "\\x{$1}");
}
/**
* Load a language and export it as a translated string to STDOUT.
*
* @param {string} lang
*/
function exportLang(lang) {
const x = nodeRequire(`${HIGHLIGHT_DIR}/languages/${lang}.js`);
const l = cloneDeep(x(hljs));
regexToStr(l);
hljs.registerLanguage(lang, x);
console.log(lang);
console.log(jsUnicodeToPhpUnicode(dojox.json.ref.toJson(l)));
}
fs.readdir(`${HIGHLIGHT_DIR}/languages/`,function(err, files) {
if (err) {
throw err;
}
// Load all of the languages that don't extend other languages
files.forEach(function(file) {
if (file === ".DS_Store" || LANGS_W_DEPS.indexOf(file) >= 0) {
return;
}
exportLang(file.replace(/\.js$/, ""));
});
// These languages extend other languages, so we need to make sure that
// they are loaded *after* all the standard languages are loaded.
LANGS_W_DEPS.forEach(function(file) {
exportLang(file.replace(/\.js$/, ""));
});
});
});