update inbox list
This commit is contained in:
5
vendor/scrivo/highlight.php/tools/.htaccess
vendored
Normal file
5
vendor/scrivo/highlight.php/tools/.htaccess
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
order deny,allow
|
||||
deny from all
|
||||
allow from 192.168.1.1/24
|
||||
allow from 10.0.0.0/8
|
||||
allow from 127.0.0.1
|
||||
82
vendor/scrivo/highlight.php/tools/export.js
vendored
Normal file
82
vendor/scrivo/highlight.php/tools/export.js
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
"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$/, ""));
|
||||
});
|
||||
});
|
||||
});
|
||||
100
vendor/scrivo/highlight.php/tools/get_language_definitions.php
vendored
Normal file
100
vendor/scrivo/highlight.php/tools/get_language_definitions.php
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/* Copyright (c)
|
||||
* - 2013-2019 Geert Bergman (geert@scrivo.nl), highlight.php
|
||||
* - 2014 Daniel Lynge, highlight.php (contributor)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of "highlight.js", "highlight.php", nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// Extract language definitions (JSON strings) from the large file that was
|
||||
// created using 'node launcher.js' and create a JSON file for each language.
|
||||
|
||||
$f = file("languages.dat");
|
||||
|
||||
$patches = array(
|
||||
// The expression \\/: causes issues for PREG due to the / and the : having special meaning, therefore we use \Q and
|
||||
// \E to have PREG treat them as literal characters
|
||||
"1c" => array(
|
||||
array("\\\\\\\\/:", "\\\\Q\\\\/:\\\\E"),
|
||||
),
|
||||
|
||||
// The expression []{}%#'" should be treated as a list of invalid characters, however the [] is special in PREG so
|
||||
// we use \Q and \E to have PREG treat them as literal characters
|
||||
"ada" => array(
|
||||
array("[]{}%#'\\\"", "\\\\Q[]{}%#'\\\"\\\\E"),
|
||||
),
|
||||
|
||||
// WTF, any ideas anyone?
|
||||
"mercury" => array(array("\\\\\\\/", "\\\\\\\\\\\/")),
|
||||
|
||||
// The expression [^] is not allowed in PREG
|
||||
"lisp" => array(array("[^]", "[^|]")),
|
||||
|
||||
// There's a typo in the Swift translation file
|
||||
"swift" => array(array(
|
||||
'{02B80}-9',
|
||||
'{02B8}0-9',
|
||||
)),
|
||||
);
|
||||
|
||||
for ($i = 0; $i < count($f); $i += 2) {
|
||||
if (!isset($f[$i + 1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$languageName = trim($f[$i]);
|
||||
$jsonLangDef = $f[$i + 1];
|
||||
|
||||
// The `-` character must be escaped in while in `[]`. This is enforced in PHP 7.3+
|
||||
// https://wiki.php.net/rfc/pcre2-migration
|
||||
// https://github.com/php/php-src/pull/2857
|
||||
$jsonLangDef = preg_replace('/(\[[^:]*?\w)(-)([^a-zA-Z0-9\\\\]+?)/um', '$1\\\\\\-$3', $jsonLangDef);
|
||||
|
||||
if (!$languageName) {
|
||||
die(sprintf("ERROR: No language name on line %d\n", ($i + 1)));
|
||||
}
|
||||
if (!@json_decode($jsonLangDef)) {
|
||||
die(sprintf("ERROR: Invalid JSON data on line %d\n", ($i + 2)));
|
||||
}
|
||||
|
||||
if (isset($patches[$languageName])) {
|
||||
foreach ($patches[$languageName] as $j => $patch) {
|
||||
$patched = str_replace($patch[0], $patch[1], $jsonLangDef);
|
||||
|
||||
if ($jsonLangDef === $patched) {
|
||||
printf("Patch %d for %s was not applied and likely unnecessary\n", $j, $languageName);
|
||||
}
|
||||
|
||||
$jsonLangDef = $patched;
|
||||
}
|
||||
}
|
||||
|
||||
$jsonLangDef = json_encode(json_decode($jsonLangDef), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) . "\n";
|
||||
|
||||
if (!file_put_contents("../Highlight/languages/{$languageName}.json", $jsonLangDef)) {
|
||||
die("ERROR: Couldn't write to file.\n");
|
||||
}
|
||||
}
|
||||
109
vendor/scrivo/highlight.php/tools/get_styles_colors.php
vendored
Normal file
109
vendor/scrivo/highlight.php/tools/get_styles_colors.php
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
use Sabberworm\CSS\Property\Selector;
|
||||
use Sabberworm\CSS\Rule\Rule;
|
||||
use Sabberworm\CSS\RuleSet\DeclarationBlock;
|
||||
use Sabberworm\CSS\Value\Color;
|
||||
use Sabberworm\CSS\Value\RuleValueList;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$finder = new Finder();
|
||||
$finder
|
||||
->in(__DIR__ . '/../styles/')
|
||||
->name('*.css')
|
||||
->sortByName()
|
||||
->files()
|
||||
;
|
||||
|
||||
$backgroundColors = array();
|
||||
|
||||
/** @var \Symfony\Component\Finder\SplFileInfo $file */
|
||||
foreach ($finder->getIterator() as $file) {
|
||||
$themeName = $file->getBasename('.css');
|
||||
$backgroundColors[$themeName] = array(
|
||||
'r' => 255,
|
||||
'g' => 255,
|
||||
'b' => 255,
|
||||
);
|
||||
$cssParser = new Sabberworm\CSS\Parser($file->getContents());
|
||||
$cssDocument = $cssParser->parse();
|
||||
|
||||
/** @var DeclarationBlock $ruleSet */
|
||||
foreach ($cssDocument->getAllRuleSets() as $ruleSet) {
|
||||
/** @var Selector $selector */
|
||||
foreach ($ruleSet->getSelectors() as $selector) {
|
||||
if ($selector->getSelector() === '.hljs') {
|
||||
$bgColor = $ruleSet->getRules('background');
|
||||
|
||||
if (empty($bgColor)) {
|
||||
$bgColor = $ruleSet->getRules('background-color');
|
||||
}
|
||||
|
||||
/** @var RuleValueList|Rule $value */
|
||||
foreach ($bgColor as $value) {
|
||||
$isColor = $value->getValue() instanceof Color;
|
||||
$isValueList = $value->getValue() instanceof RuleValueList;
|
||||
|
||||
if (!$isColor && !$isValueList) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($isColor) {
|
||||
$colorValue = $value->getValue()->getColor();
|
||||
} elseif ($isValueList) {
|
||||
/** @var RuleValueList $valueList */
|
||||
foreach ($value->getValue()->getListComponents() as $valueList) {
|
||||
if ($valueList instanceof Color) {
|
||||
$colorValue = $valueList->getColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$backgroundColors[$themeName] = array(
|
||||
'r' => $colorValue['r']->getSize(),
|
||||
'g' => $colorValue['g']->getSize(),
|
||||
'b' => $colorValue['b']->getSize(),
|
||||
);
|
||||
|
||||
break 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$document = <<<'PHP'
|
||||
<?php
|
||||
|
||||
// DO NOT MODIFY. This file is automatically generated.
|
||||
|
||||
/**
|
||||
* Get the background color for a specific CSS theme.
|
||||
*
|
||||
* @param string $theme The theme name
|
||||
*
|
||||
* @throws \DomainException when no stylesheet with this name exists
|
||||
*
|
||||
* @return float[]
|
||||
*/
|
||||
function _getThemeBackgroundColor($theme)
|
||||
{
|
||||
$colors = {colorMapping};
|
||||
|
||||
if (!isset($colors[$theme])) {
|
||||
throw new DomainException("There is no stylesheet by the name of '$theme'");
|
||||
}
|
||||
|
||||
return $colors[$theme];
|
||||
}
|
||||
|
||||
PHP;
|
||||
|
||||
$document = strtr($document, array(
|
||||
'{colorMapping}' => var_export($backgroundColors, true),
|
||||
));
|
||||
|
||||
file_put_contents(__DIR__ . '/../HighlightUtilities/_themeColors.php', $document);
|
||||
16
vendor/scrivo/highlight.php/tools/launcher.js
vendored
Normal file
16
vendor/scrivo/highlight.php/tools/launcher.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
dojoConfig = {
|
||||
async: true,
|
||||
baseUrl: "lib_dojo/",
|
||||
packages: [{
|
||||
name: "dojo",
|
||||
location: "dojo"
|
||||
},{
|
||||
name: "dojox",
|
||||
location: "dojox"
|
||||
}],
|
||||
deps: ["export"],
|
||||
highlightJsDir: __dirname + "/lib_highlight/build/lib",
|
||||
cwd: __dirname,
|
||||
};
|
||||
|
||||
require("./lib_dojo/dojo/dojo.js");
|
||||
1748
vendor/scrivo/highlight.php/tools/lodash.cloneDeep.js
vendored
Normal file
1748
vendor/scrivo/highlight.php/tools/lodash.cloneDeep.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
42
vendor/scrivo/highlight.php/tools/process.sh
vendored
Normal file
42
vendor/scrivo/highlight.php/tools/process.sh
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
HLJS_V="9.18.1"
|
||||
DOJO_V="1.13.0"
|
||||
|
||||
HLJS_DL="https://api.github.com/repos/highlightjs/highlight.js/tarball/$HLJS_V"
|
||||
DOJO_DL="http://download.dojotoolkit.org/release-$DOJO_V/dojo-release-$DOJO_V-src.tar.gz"
|
||||
|
||||
curl -L $HLJS_DL --output "lib_highlight.tar.gz"
|
||||
curl -L $DOJO_DL --output "lib_dojo.tar.gz"
|
||||
|
||||
rm -rf lib_dojo lib_highlight 2> /dev/null
|
||||
|
||||
mkdir lib_dojo lib_highlight
|
||||
|
||||
tar xzf lib_dojo.tar.gz -C lib_dojo --strip-components 1
|
||||
tar xzf lib_highlight.tar.gz -C lib_highlight --strip-components 1
|
||||
|
||||
cd lib_highlight
|
||||
npm install
|
||||
node tools/build.js -t node
|
||||
|
||||
# Translate language definitions to something Highlight.php can handle
|
||||
cd ..
|
||||
node launcher.js > languages.dat
|
||||
php get_language_definitions.php
|
||||
|
||||
# Copy styles from highlight.js to our own styles directory
|
||||
rm -r ../styles/ 2> /dev/null
|
||||
mkdir -p ../styles/
|
||||
cp -a lib_highlight/src/styles/ ../styles/
|
||||
php get_styles_colors.php
|
||||
|
||||
# Copy unit tests
|
||||
rm -r ../test/detect/ 2> /dev/null
|
||||
rm -r ../test/markup/ 2> /dev/null
|
||||
|
||||
mkdir -p ../test/{detect,markup}/
|
||||
cp -a lib_highlight/test/detect/ ../test/detect/
|
||||
cp -a lib_highlight/test/markup/ ../test/markup/
|
||||
|
||||
rm ../test/{detect,markup}/index.js 2> /dev/null
|
||||
Reference in New Issue
Block a user