first commit

This commit is contained in:
Anton McClure 2020-07-01 18:43:11 -04:00
commit a2b2de5b2f
No known key found for this signature in database
GPG Key ID: 95F468320CF39788
98 changed files with 20759 additions and 0 deletions

5
README.md Normal file
View File

@ -0,0 +1,5 @@
# site
The code powering the Summit pubnix website.
## To-Do
(Coming soon)

11
composer.json Normal file
View File

@ -0,0 +1,11 @@
{
"require": {
"tildeverse/wiki": "dev-master"
},
"repositories": [
{
"type": "vcs",
"url": "https://tildegit.org/ben/tildewiki"
}
]
}

292
composer.lock generated Normal file
View File

@ -0,0 +1,292 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "3ab3df15c4e40417f427b37691e83088",
"packages": [
{
"name": "erusev/parsedown",
"version": "1.7.4",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown.git",
"reference": "cb17b6477dfff935958ba01325f2e8a2bfa6dab3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/cb17b6477dfff935958ba01325f2e8a2bfa6dab3",
"reference": "cb17b6477dfff935958ba01325f2e8a2bfa6dab3",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
},
"type": "library",
"autoload": {
"psr-0": {
"Parsedown": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "Parser for Markdown.",
"homepage": "http://parsedown.org",
"keywords": [
"markdown",
"parser"
],
"time": "2019-12-30T22:54:17+00:00"
},
{
"name": "erusev/parsedown-extra",
"version": "0.7.1",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown-extra.git",
"reference": "0db5cce7354e4b76f155d092ab5eb3981c21258c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown-extra/zipball/0db5cce7354e4b76f155d092ab5eb3981c21258c",
"reference": "0db5cce7354e4b76f155d092ab5eb3981c21258c",
"shasum": ""
},
"require": {
"erusev/parsedown": "~1.4"
},
"type": "library",
"autoload": {
"psr-0": {
"ParsedownExtra": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "An extension of Parsedown that adds support for Markdown Extra.",
"homepage": "https://github.com/erusev/parsedown-extra",
"keywords": [
"markdown",
"markdown extra",
"parsedown",
"parser"
],
"time": "2015-11-01T10:19:22+00:00"
},
{
"name": "mnapoli/front-yaml",
"version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/mnapoli/FrontYAML.git",
"reference": "24070ace8b741247bb3161cbb38ecc541268b296"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mnapoli/FrontYAML/zipball/24070ace8b741247bb3161cbb38ecc541268b296",
"reference": "24070ace8b741247bb3161cbb38ecc541268b296",
"shasum": ""
},
"require": {
"erusev/parsedown": "~1.0",
"php": ">=5.4.0",
"symfony/yaml": "~2.1|^3.0|^4.0"
},
"require-dev": {
"league/commonmark": "~0.7",
"phpunit/phpunit": "~4.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Mni\\FrontYAML\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"time": "2017-10-29T19:29:55+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.14.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38",
"reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.14-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2020-01-13T11:15:53+00:00"
},
{
"name": "symfony/yaml",
"version": "v4.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "cd014e425b3668220adb865f53bff64b3ad21767"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/cd014e425b3668220adb865f53bff64b3ad21767",
"reference": "cd014e425b3668220adb865f53bff64b3ad21767",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/polyfill-ctype": "~1.8"
},
"conflict": {
"symfony/console": "<3.4"
},
"require-dev": {
"symfony/console": "^3.4|^4.0|^5.0"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2020-01-21T11:12:16+00:00"
},
{
"name": "tildeverse/wiki",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://tildegit.org/ben/tildewiki",
"reference": "751eb64c383cb7c6ec643eaf683b88aa1de351ea"
},
"require": {
"erusev/parsedown-extra": "^0.7.1",
"mnapoli/front-yaml": "^1.6"
},
"type": "library",
"autoload": {
"psr-4": {
"Tildeverse\\Wiki\\": "src/"
}
},
"license": [
"GPLv3"
],
"authors": [
{
"name": "Ben Harris",
"email": "ben@tilde.team"
}
],
"description": "parsedown extensions for tilde wikis",
"time": "2019-07-03T05:06:34+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"tildeverse/wiki": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}

14
config.json Normal file
View File

@ -0,0 +1,14 @@
{
"email": {
"from": "amcclure@summit.tildex.com",
"to": "amcclure@summit.tildex.com"
},
"endpoints": [
{
"repo": "SummitTilde/site",
"branch": "master",
"action": "something has been changed on the server",
"run": "./update.sh"
}
]
}

8
contact/index.php Normal file
View File

@ -0,0 +1,8 @@
<?php require_once '/var/www/tilde/server/header1.php';
$PageTitle = "Contact";
require_once '/var/www/tilde/server/header2.php'; ?>
<p>General: <a href="javascript:location='mailto:\u0063\u006f\u006e\u0074\u0061\u0063\u0074\u0040\u0073\u0075\u006d\u006d\u0069\u0074\u002e\u0074\u0069\u006c\u0064\u0065\u0078\u002e\u0063\u006f\u006d';void 0"><script type="text/javascript">document.write('\u0063\u006f\u006e\u0074\u0061\u0063\u0074\u0040\u0073\u0075\u006d\u006d\u0069\u0074\u002e\u0074\u0069\u006c\u0064\u0065\u0078\u002e\u0063\u006f\u006d')</script></a></p>
<p>Abuse: <a href="javascript:location='mailto:\u0061\u0062\u0075\u0073\u0065\u0040\u0073\u0075\u006d\u006d\u0069\u0074\u002e\u0074\u0069\u006c\u0064\u0065\u0078\u002e\u0063\u006f\u006d';void 0"><script type="text/javascript">document.write('\u0061\u0062\u0075\u0073\u0065\u0040\u0073\u0075\u006d\u006d\u0069\u0074\u002e\u0074\u0069\u006c\u0064\u0065\u0078\u002e\u0063\u006f\u006d')</script></a></p>
<p>Administration: <a href="javascript:location='mailto:\u0061\u0064\u006d\u0069\u006e\u0073\u0040\u0073\u0075\u006d\u006d\u0069\u0074\u002e\u0074\u0069\u006c\u0064\u0065\u0078\u002e\u0063\u006f\u006d';void 0"><script type="text/javascript">document.write('\u0061\u0064\u006d\u0069\u006e\u0073\u0040\u0073\u0075\u006d\u006d\u0069\u0074\u002e\u0074\u0069\u006c\u0064\u0065\u0078\u002e\u0063\u006f\u006d')</script></a></p>
<p>Owner: <a href="javascript:location='mailto:\u0070\u0075\u0062\u006e\u0069\u0078\u0040\u0061\u006e\u0074\u006f\u006e\u006d\u0063\u0063\u006c\u0075\u0072\u0065\u002e\u0063\u006f\u006d';void 0"><script type="text/javascript">document.write('\u0070\u0075\u0062\u006e\u0069\u0078\u0040\u0061\u006e\u0074\u006f\u006e\u006d\u0063\u0063\u006c\u0075\u0072\u0065\u002e\u0063\u006f\u006d')</script></a></p>
<?php require_once '/var/www/tilde/server/footer.php' ?>

9861
email/Net/DNS2.php Normal file

File diff suppressed because it is too large Load Diff

210
email/ipaddr.php Normal file
View File

@ -0,0 +1,210 @@
<?php
// CubicleSoft PHP IP Address functions.
// (C) 2013 CubicleSoft. All Rights Reserved.
class IPAddr
{
static function NormalizeIP($ipaddr)
{
$ipv4addr = "";
$ipv6addr = "";
// Generate IPv6 address.
$ipaddr = strtolower(trim($ipaddr));
if (strpos($ipaddr, ":") === false) $ipaddr = "::ffff:" . $ipaddr;
$ipaddr = explode(":", $ipaddr);
if (count($ipaddr) < 3) $ipaddr = array("", "", "0");
$ipaddr2 = array();
$foundpos = false;
foreach ($ipaddr as $num => $segment)
{
$segment = trim($segment);
if ($segment != "") $ipaddr2[] = $segment;
else if ($foundpos === false && count($ipaddr) > $num + 1 && $ipaddr[$num + 1] != "")
{
$foundpos = count($ipaddr2);
$ipaddr2[] = "0000";
}
}
// Convert ::ffff:123.123.123.123 format.
if (strpos($ipaddr2[count($ipaddr2) - 1], ".") !== false)
{
$x = count($ipaddr2) - 1;
if ($ipaddr2[count($ipaddr2) - 2] != "ffff") $ipaddr2[$x] = "0";
else
{
$ipaddr = explode(".", $ipaddr2[$x]);
if (count($ipaddr) != 4) $ipaddr2[$x] = "0";
else
{
$ipaddr2[$x] = str_pad(strtolower(dechex($ipaddr[0])), 2, "0", STR_PAD_LEFT) . str_pad(strtolower(dechex($ipaddr[1])), 2, "0", STR_PAD_LEFT);
$ipaddr2[] = str_pad(strtolower(dechex($ipaddr[2])), 2, "0", STR_PAD_LEFT) . str_pad(strtolower(dechex($ipaddr[3])), 2, "0", STR_PAD_LEFT);
}
}
}
$ipaddr = array_slice($ipaddr2, 0, 8);
if ($foundpos !== false && count($ipaddr) < 8) array_splice($ipaddr, $foundpos, 0, array_fill(0, 8 - count($ipaddr), "0000"));
foreach ($ipaddr as $num => $segment)
{
$ipaddr[$num] = substr(str_pad(strtolower(dechex(hexdec($segment))), 4, "0", STR_PAD_LEFT), -4);
}
$ipv6addr = implode(":", $ipaddr);
// Extract IPv4 address.
if (substr($ipv6addr, 0, 30) == "0000:0000:0000:0000:0000:ffff:") $ipv4addr = hexdec(substr($ipv6addr, 30, 2)) . "." . hexdec(substr($ipv6addr, 32, 2)) . "." . hexdec(substr($ipv6addr, 35, 2)) . "." . hexdec(substr($ipv6addr, 37, 2));
// Make a short IPv6 address.
$shortipv6 = $ipv6addr;
$pattern = "0000:0000:0000:0000:0000:0000:0000";
do
{
$shortipv6 = str_replace($pattern, ":", $shortipv6);
$pattern = substr($pattern, 5);
} while (strlen($shortipv6) == 39 && $pattern != "");
$shortipv6 = explode(":", $shortipv6);
foreach ($shortipv6 as $num => $segment)
{
if ($segment != "") $shortipv6[$num] = strtolower(dechex(hexdec($segment)));
}
$shortipv6 = implode(":", $shortipv6);
return array("ipv6" => $ipv6addr, "shortipv6" => $shortipv6, "ipv4" => $ipv4addr);
}
static function GetRemoteIP($proxies = array())
{
$ipaddr = self::NormalizeIP(isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : "127.0.0.1");
// Check for trusted proxies. Stop at first untrusted IP in the chain.
if (isset($proxies[$ipaddr["ipv6"]]) || ($ipaddr["ipv4"] != "" && isset($proxies[$ipaddr["ipv4"]])))
{
$xforward = (isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? explode(",", $_SERVER["HTTP_X_FORWARDED_FOR"]) : array());
$clientip = (isset($_SERVER["HTTP_CLIENT_IP"]) ? explode(",", $_SERVER["HTTP_CLIENT_IP"]) : array());
do
{
$found = false;
if (isset($proxies[$ipaddr["ipv6"]])) $header = $proxies[$ipaddr["ipv6"]];
else $header = $proxies[$ipaddr["ipv4"]];
$header = strtolower($header);
if ($header == "xforward" && count($xforward) > 0)
{
$ipaddr = self::NormalizeIP(array_pop($xforward));
$found = true;
}
else if ($header == "clientip" && count($clientip) > 0)
{
$ipaddr = self::NormalizeIP(array_pop($clientip));
$found = true;
}
} while ($found && (isset($proxies[$ipaddr["ipv6"]]) || ($ipaddr["ipv4"] != "" && isset($proxies[$ipaddr["ipv4"]]))));
}
return $ipaddr;
}
static function IsMatch($pattern, $ipaddr)
{
if (is_string($ipaddr)) $ipaddr = self::NormalizeIP($ipaddr);
if (strpos($pattern, ":") !== false)
{
// Pattern is IPv6.
$pattern = explode(":", strtolower($pattern));
$ipaddr = explode(":", $ipaddr["ipv6"]);
if (count($pattern) != 8 || count($ipaddr) != 8) return false;
foreach ($pattern as $num => $segment)
{
$found = false;
$pieces = explode(",", $segment);
foreach ($pieces as $piece)
{
$piece = trim($piece);
$piece = explode(".", $piece);
if (count($piece) == 1)
{
$piece = $piece[0];
if ($piece == "*") $found = true;
else if (strpos($piece, "-") !== false)
{
$range = explode("-", $piece);
$range[0] = hexdec($range[0]);
$range[1] = hexdec($range[1]);
$val = hexdec($ipaddr[$num]);
if ($range[0] > $range[1]) $range[0] = $range[1];
if ($val >= $range[0] && $val <= $range[1]) $found = true;
}
else if ($piece === $ipaddr[$num]) $found = true;
}
else if (count($piece) == 2)
{
// Special IPv4-like notation.
$found2 = false;
$found3 = false;
$val = hexdec(substr($ipaddr[$num], 0, 2));
$val2 = hexdec(substr($ipaddr[$num], 2, 2));
if ($piece[0] == "*") $found2 = true;
else if (strpos($piece[0], "-") !== false)
{
$range = explode("-", $piece[0]);
if ($range[0] > $range[1]) $range[0] = $range[1];
if ($val >= $range[0] && $val <= $range[1]) $found2 = true;
}
else if ($piece[0] == $val) $found2 = true;
if ($piece[1] == "*") $found3 = true;
else if (strpos($piece[1], "-") !== false)
{
$range = explode("-", $piece[1]);
if ($range[0] > $range[1]) $range[0] = $range[1];
if ($val >= $range[0] && $val <= $range[1]) $found3 = true;
}
else if ($piece[1] == $val2) $found3 = true;
if ($found2 && $found3) $found = true;
}
if ($found) break;
}
if (!$found) return false;
}
}
else
{
// Pattern is IPv4.
$pattern = explode(".", strtolower($pattern));
$ipaddr = explode(".", $ipaddr["ipv4"]);
if (count($pattern) != 4 || count($ipaddr) != 4) return false;
foreach ($pattern as $num => $segment)
{
$found = false;
$pieces = explode(",", $segment);
foreach ($pieces as $piece)
{
$piece = trim($piece);
if ($piece == "*") $found = true;
else if (strpos($piece, "-") !== false)
{
$range = explode("-", $piece);
if ($range[0] > $range[1]) $range[0] = $range[1];
if ($ipaddr[$num] >= $range[0] && $ipaddr[$num] <= $range[1]) $found = true;
}
else if ($piece == $ipaddr[$num]) $found = true;
if ($found) break;
}
if (!$found) return false;
}
}
return true;
}
}
?>

1519
email/smtp.php Normal file

File diff suppressed because it is too large Load Diff

208
email/utf8.php Normal file
View File

@ -0,0 +1,208 @@
<?php
// CubicleSoft PHP UTF8 (Unicode) functions.
// (C) 2014 CubicleSoft. All Rights Reserved.
class UTF8
{
// Removes invalid characters from the data string.
// http://www.w3.org/International/questions/qa-forms-utf-8
public static function MakeValid($data)
{
$result = "";
$x = 0;
$y = strlen($data);
while ($x < $y)
{
$tempchr = ord($data[$x]);
if ($y - $x > 1) $tempchr2 = ord($data[$x + 1]);
else $tempchr2 = 0x00;
if ($y - $x > 2) $tempchr3 = ord($data[$x + 2]);
else $tempchr3 = 0x00;
if ($y - $x > 3) $tempchr4 = ord($data[$x + 3]);
else $tempchr4 = 0x00;
if ($tempchr == 0x09 || $tempchr == 0x0A || $tempchr == 0x0D || ($tempchr >= 0x20 && $tempchr <= 0x7E))
{
// ASCII minus control and special characters.
$result .= chr($tempchr);
$x++;
}
else if (($tempchr >= 0xC2 && $tempchr <= 0xDF) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF))
{
// Non-overlong (2 bytes).
$result .= chr($tempchr);
$result .= chr($tempchr2);
$x += 2;
}
else if ($tempchr == 0xE0 && ($tempchr2 >= 0xA0 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF))
{
// Non-overlong (3 bytes).
$result .= chr($tempchr);
$result .= chr($tempchr2);
$result .= chr($tempchr3);
$x += 3;
}
else if ((($tempchr >= 0xE1 && $tempchr <= 0xEC) || $tempchr == 0xEE || $tempchr == 0xEF) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF))
{
// Normal/straight (3 bytes).
$result .= chr($tempchr);
$result .= chr($tempchr2);
$result .= chr($tempchr3);
$x += 3;
}
else if ($tempchr == 0xED && ($tempchr2 >= 0x80 && $tempchr2 <= 0x9F) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF))
{
// Non-surrogates (3 bytes).
$result .= chr($tempchr);
$result .= chr($tempchr2);
$result .= chr($tempchr3);
$x += 3;
}
else if ($tempchr == 0xF0 && ($tempchr2 >= 0x90 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF))
{
// Planes 1-3 (4 bytes).
$result .= chr($tempchr);
$result .= chr($tempchr2);
$result .= chr($tempchr3);
$result .= chr($tempchr4);
$x += 4;
}
else if (($tempchr >= 0xF1 && $tempchr <= 0xF3) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF))
{
// Planes 4-15 (4 bytes).
$result .= chr($tempchr);
$result .= chr($tempchr2);
$result .= chr($tempchr3);
$result .= chr($tempchr4);
$x += 4;
}
else if ($tempchr == 0xF4 && ($tempchr2 >= 0x80 && $tempchr2 <= 0x8F) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF))
{
// Plane 16 (4 bytes).
$result .= chr($tempchr);
$result .= chr($tempchr2);
$result .= chr($tempchr3);
$result .= chr($tempchr4);
$x += 4;
}
else $x++;
}
return $result;
}
public static function IsValid($data)
{
$x = 0;
$y = strlen($data);
while ($x < $y)
{
$tempchr = ord($data[$x]);
if ($y - $x > 1) $tempchr2 = ord($data[$x + 1]);
else $tempchr2 = 0x00;
if ($y - $x > 2) $tempchr3 = ord($data[$x + 2]);
else $tempchr3 = 0x00;
if ($y - $x > 3) $tempchr4 = ord($data[$x + 3]);
else $tempchr4 = 0x00;
if ($tempchr == 0x09 || $tempchr == 0x0A || $tempchr == 0x0D || ($tempchr >= 0x20 && $tempchr <= 0x7E)) $x++;
else if (($tempchr >= 0xC2 && $tempchr <= 0xDF) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF)) $x += 2;
else if ($tempchr == 0xE0 && ($tempchr2 >= 0xA0 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF)) $x += 3;
else if ((($tempchr >= 0xE1 && $tempchr <= 0xEC) || $tempchr == 0xEE || $tempchr == 0xEF) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF)) $x += 3;
else if ($tempchr == 0xED && ($tempchr2 >= 0x80 && $tempchr2 <= 0x9F) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF)) $x += 3;
else if ($tempchr == 0xF0 && ($tempchr2 >= 0x90 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF)) $x += 4;
else if (($tempchr >= 0xF1 && $tempchr <= 0xF3) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF)) $x += 4;
else if ($tempchr == 0xF4 && ($tempchr2 >= 0x80 && $tempchr2 <= 0x8F) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF)) $x += 4;
else return false;
}
return true;
}
// Locates the next UTF8 character in a UTF8 string.
// Set Pos and Size to 0 to start at the beginning.
// Returns false at the end of the string or bad UTF8 character. Otherwise, returns true.
public static function NextChrPos(&$data, $datalen, &$pos, &$size)
{
$pos += $size;
$size = 0;
$x = $pos;
$y = $datalen;
if ($x >= $y) return false;
$tempchr = ord($data[$x]);
if ($y - $x > 1) $tempchr2 = ord($data[$x + 1]);
else $tempchr2 = 0x00;
if ($y - $x > 2) $tempchr3 = ord($data[$x + 2]);
else $tempchr3 = 0x00;
if ($y - $x > 3) $tempchr4 = ord($data[$x + 3]);
else $tempchr4 = 0x00;
if ($tempchr == 0x09 || $tempchr == 0x0A || $tempchr == 0x0D || ($tempchr >= 0x20 && $tempchr <= 0x7E)) $size = 1;
else if (($tempchr >= 0xC2 && $tempchr <= 0xDF) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF)) $size = 2;
else if ($tempchr == 0xE0 && ($tempchr2 >= 0xA0 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF)) $size = 3;
else if ((($tempchr >= 0xE1 && $tempchr <= 0xEC) || $tempchr == 0xEE || $tempchr == 0xEF) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF)) $size = 3;
else if ($tempchr == 0xED && ($tempchr2 >= 0x80 && $tempchr2 <= 0x9F) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF)) $size = 3;
else if ($tempchr == 0xF0 && ($tempchr2 >= 0x90 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF)) $size = 4;
else if (($tempchr >= 0xF1 && $tempchr <= 0xF3) && ($tempchr2 >= 0x80 && $tempchr2 <= 0xBF) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF)) $size = 4;
else if ($tempchr == 0xF4 && ($tempchr2 >= 0x80 && $tempchr2 <= 0x8F) && ($tempchr3 >= 0x80 && $tempchr3 <= 0xBF) && ($tempchr4 >= 0x80 && $tempchr4 <= 0xBF)) $size = 4;
else return false;
return true;
}
// Determines if a UTF8 string can also be viewed as ASCII.
public static function IsASCII($data)
{
$pos = 0;
$size = 0;
$y = strlen($data);
while (self::NextChrPos($data, $y, $pos, $size) && $size == 1) {}
if ($pos < $y || $size > 1) return false;
return true;
}
// Returns the number of characters in a UTF8 string.
public static function strlen($data)
{
$num = 0;
$pos = 0;
$size = 0;
$y = strlen($data);
while (self::NextChrPos($data, $y, $pos, $size)) $num++;
return $num;
}
// Converts a UTF8 string to ASCII and drops bad UTF8 and non-ASCII characters in the process.
public static function ConvertToASCII($data)
{
$result = "";
$pos = 0;
$size = 0;
$y = strlen($data);
while ($pos < $y)
{
if (self::NextChrPos($data, $y, $pos, $size) && $size == 1) $result .= $data[$pos];
else if (!$size) $size = 1;
}
return $result;
}
// Converts UTF8 characters in a string to HTML entities.
public static function ConvertToHTML($data)
{
return preg_replace_callback('/([\xC0-\xF7]{1,1}[\x80-\xBF]+)/', 'UTF8::ConvertToHTML__Callback', $data);
}
private static function ConvertToHTML__Callback($data)
{
$data = $data[1];
$num = 0;
$data = str_split(strrev(chr((ord(substr($data, 0, 1)) % 252 % 248 % 240 % 224 % 192) + 128) . substr($data, 1)));
foreach ($data as $k => $v) $num += (ord($v) % 128) * pow(64, $k);
return "&#" . $num . ";";
}
}
?>

17
faq/index.php Normal file
View File

@ -0,0 +1,17 @@
<?php require_once '/var/www/tilde/server/header1.php';
$PageTitle = "Frequently Asked Questions";
require_once '/var/www/tilde/server/header2.php'; ?>
<dl>
<dt><strong>What is summit?</strong></dt>
<dd>summit is a free (as in freedom and beer) Linux-powered community.</dd>
<br>
<dt><strong>Do I need to be good at Linux or UNIX to join?</strong></dt>
<dd>Not at all! One of the focuses for summit pubnix is learning.</dd>
<br>
<dt><strong>Can I have a package installed or something changed?</strong></dt>
<dd>Sure. We want our system and services to be as useful as possible. Feel free to contact <code>anton</code> on irc.tilde.chat #summit.</dd>
<br>
<dt><strong>How do I use SSH?</strong></dt>
<dd>Feel free to take a look at Anton's <a href="https://www.antonmcclure.com/guides/openssh">SSH guide</a>.
</dl>
<?php require_once '/var/www/tilde/server/footer.php' ?>

61
index.php Normal file
View File

@ -0,0 +1,61 @@
<?php require_once '/var/www/tilde/server/header1.php';
$PageTitle = "Welcome to Summit Pubnix";
require_once '/var/www/tilde/server/header2.php'; ?>
<p>summit is an intentional and inclusive community for developing, making, learning, teaching, socializing, and enjoying various aspects of GNU/Linux in a free/non-commercial environment. If you need help or have any questions, feel free to ask in <a href="https://webchat.reenode.net/##pubnix">##pubnix</a> on <a href="ircs://chat.freenode.net"><code>chat.freenode.net</code></a>.</p>
<p>summit tries to adhere to the values and philosophy of the Hacker Ethic whenever possible. The hacker ethics and beliefs as described by Levy are:</p>
<ul>
<li>Access to computers - and anything which might teach you something about the way the world works - should be unlimited and total. Always yield to the Hands-On Imperative!</li>
<li>All information should be free</li>
<li>Mistrust authority - promote decentralization</li>
<li>Hackers should be judged by their hacking, not criteria such as degrees, age, race, sex, or position</li>
<li>You can create art and beauty on a computer</li>
<li>Computers can change your life for the better</li>
</ul>
<div class="row">
<div class="col-lg-6">
<td valign="top" width="50%"><h3>News</h3>
<p><a href="/news/">news archive here...</a></p>
<?php foreach (array_slice(array_reverse(glob("news/pages/*.md")), 0, 4) as $page):
$parsed = $parser->parse(file_get_contents($page));
$yaml = $parsed->getYAML();
if (!$yaml["published"]) continue; ?>
<table border="1" width="100%">
<tr>
<th colspan="2">
<center><a href="/news/<?=basename($page, ".md")?>"><?=$yaml["title"]?></a></center>
</th>
</tr>
<tr>
<td width="50%">
<center><?=$yaml["date"]?></center>
</td>
<td width="50%">
<center><a href="/~<?=$yaml["author"]?>/"><?=$yaml["author"]?></a></center>
</td>
</tr>
</table>
<?php endforeach; ?>
</div>
<div class="col-lg-6">
<h3>Users</h3>
<ul>
<?php
foreach (glob("/home/*") as $nameUser):
$nameUser = basename($nameUser);
$nameFull = exec("awk -v user='$nameUser' -F':' 'user==$1{print $5}' /etc/passwd");?>
<li><?=$nameFull?> (~<?=$nameUser?>) &mdash; <a href="/~<?=$nameUser?>/">web</a>, <a href="gopher://summit.tildex.com/~<?=$nameUser?>/">gopher</a></li>
<?php endforeach; ?>
</ul>
</div>
<div class="col-lg-6">
<h3>Projects</h3>
(Coming soon)
</div>
<div class="col-lg-6">
<h3>Mastodon</h3>
<iframe allowfullscreen sandbox="allow-top-navigation allow-scripts" width="100%" height="540"
src="https://www.mastofeed.com/api/feed?url=https%3A%2F%2Ftilde.zone%2Fusers%2Fsummit&size=100&header=true&replies=true&boosts=true"></iframe>
</div>
</div>
<?php require_once '/var/www/tilde/server/footer.php' ?>

19
join/index.php Normal file
View File

@ -0,0 +1,19 @@
<?php require_once '/var/www/tilde/server/header1.php';
$PageTitle = "Join summit";
require_once '/var/www/tilde/server/header2.php'; ?>
<p><strong>Thank you for your interest in joining summit!</strong></p>
<p>Please fill out this form and we will get back to you as soon as possible.</p>
<p>Note: What you enter for "Your full name or pseudonym" and "Your desired username" if accepted will be visible on the home page in the Users section as "Fullname/pseudonym (~username)". If you do not wish to enter your full name, your username will be sufficient.
<hr>
<form method="post">
<?php include './signup-handler.php'; ?>
<p><input name="fullname" type="text" class="form-control" placeholder="Your Full Name" required=""></p>
<p><input name="username" type="text" class="form-control" placeholder="Your Desired Username (numbers and lowercase letters only, no spaces)" required=""></p>
<p><input name="email" type="text" class="form-control" placeholder="Contact Email Address" required=""></p>
<p><textarea name="interest" class="form-control" rows="10" placeholder="What Interests You About Summit" required=""></textarea></p>
<p><textarea name="sshkey" class="form-control" rows="10" placeholder="Your SSH Public Key (ED25519 Preferred)" required=""></textarea></p>
<p><em>By signing up and using summit and/or Tildeverse services I agree to summit's <a href="https://www.antonmcclure.com/legal/summit-conduct">Code of Conduct</a> and <a href="https://www.antonmcclure.com/legal/summit-privacy">Privacy Policy</a> for summit services.</label></p>
</em></p>
<p><input name="submit" type="submit" class="btn-block" value="Send Message"></p>
</form>
<?php require_once '/var/www/tilde/server/footer.php' ?>

149
join/signup-handler.php Normal file
View File

@ -0,0 +1,149 @@
<?php
require_once "../email/smtp.php";
function forbidden_name($name) {
return in_array($name, [
'0x0',
'abuse',
'admin',
'anton',
'amcclure',
'zenith',
'summit',
'administrator',
'auth',
'autoconfig',
'bbj',
'broadcasthost',
'cloud',
'forum',
'ftp',
'git',
'gopher',
'hostmaster',
'imap',
'info',
'irc',
'is',
'isatap',
'it',
'localdomain',
'localhost',
'lounge',
'mail',
'mailer-daemon',
'marketing',
'marketting',
'mis',
'news',
'nobody',
'noc',
'noreply',
'oracle',
'pop',
'pop3',
'postmaster',
'register',
'retro',
'root',
'sales',
'security',
'signup',
'smtp',
'ssladmin',
'ssladministrator',
'sslwebmaster',
'summit',
'support',
'sysadmin',
'team',
'thunix',
'usenet',
'uucp',
'webmaster',
'wpad',
'www',
'znc',
]);
}
$message = "";
if (isset($_REQUEST["username"]) && isset($_REQUEST["email"]) && isset($_REQUEST["fullname"])) {
// Check the name.
$fullname = trim($_REQUEST["fullname"]);
if ($fullname == "")
$message .= "<li>Enter your full name</li>";
// Check the name.
$name = trim($_REQUEST["username"]);
if ($name == "")
$message .= "<li>Enter a username</li>";
if (strlen($name) > 32)
$message .= "<li>username too long (32 character max)</li>";
if (!preg_match('/^[a-z][a-z0-9]{2,31}$/', $name))
$message .= "<li>Username contains invalid characters (lowercase only, must start with a letter)</li>";
if ($_REQUEST["sshkey"] == "" || mb_substr($_REQUEST["sshkey"], 0, 4) !== "ssh-")
$message .= '<li>SSH key required: please create one and submit the public key.</li>';
if ($_REQUEST["interest"] == "")
$message .= "<li>Please explain why you're interested so we can make sure you're a real human being</li>";
if (posix_getpwnam($name) || forbidden_name($name))
$message .= "<li>Sorry, the username $name is unavailable</li>";
// Check the e-mail address.
$email = trim($_REQUEST["email"]);
if ($email == "")
$message .= "<li>Please fill in your email address</li>";
else {
$result = SMTP::MakeValidEmailAddress($_REQUEST["email"]);
if (!$result["success"])
$message .= "<li>invalid email address: " . htmlspecialchars($result["error"]) . "</li>";
elseif ($result["email"] != $email)
$message .= "<li>invalid email address. did you mean: " . htmlspecialchars($result["email"]) . "</li>";
}
// no validation errors
if ($message == "") {
$sshkey = trim($_REQUEST["sshkey"]);
$makeuser = "./makeuser {$_REQUEST["username"]} \"{$fullname}\" {$_REQUEST["email"]} \"{$sshkey}\"";
$msgbody = "
Full name: {$_REQUEST["fullname"]}
Username: {$_REQUEST["username"]}
Email address: {$_REQUEST["email"]}
Reason:
{$_REQUEST["interest"]}
SSH Key:
{$_REQUEST["sshkey"]}
$makeuser
";
if (mail('root', 'New registration request', $msgbody)) {
header("Location: /success.php");
file_put_contents("/var/signups", $makeuser.PHP_EOL, FILE_APPEND);
// validation errors
} else {
echo '<div class="alert alert-danger" role="alert">
Something went wrong... Please send an email to <a href="mailto:admin@summit.tildex.com">admin@summit.tildex.com</a> with details of what happened
</div>';
}
} else {
?>
<div class="message" role="alert">
<strong>Please correct the following errors before continuing: </strong>
<?=$message?>
</div>
<?php
}
}
?>

8
join/submit/index.php Normal file
View File

@ -0,0 +1,8 @@
<?php require_once '/var/www/tilde/server/header1.php' ?>
Message sent successfully!
<?php require_once '/var/www/tilde/server/header2.php' ?>
Message sent successfully!
<?php require_once '/var/www/tilde/server/header3.php' ?>
<p>Email sent! We'll get back to you soon (usually within a day)</p>
<p><a href="/">back to summit home page</a>.</p>
<?php require_once '/var/www/tilde/server/footer.php' ?>

35
news/index.php Normal file
View File

@ -0,0 +1,35 @@
<?php
if (!isset($_GET["page"]) || !file_exists("pages/{$_GET['page']}.md")) {
$title = "Summit News";
?>
<?php require_once '/var/www/tilde/server/header1.php' ?>
<?php require_once '/var/www/tilde/server/header2.php' ?>
<p>If you want to contribute, check out the
<a href="https://tildegit.org/pubnix/site/src/branch/master/news">source repo</a> and open a PR!
</p>
<hr />
<div class="content">
<h3>updates:</h3>
<?php
foreach (array_reverse(glob("pages/*.md")) as $page) {
$yaml = $parser->parse(file_get_contents($page))->getYAML();
if (!$yaml["published"]) continue; ?>
<a href="<?=basename($page, ".md")?>"><?=$yaml["title"]?></a> - <?=$yaml["date"]?><br>
<?php }
} else {
require_once '/var/www/tilde/server/header1.php';
$pg = $parser->parse(file_get_contents("pages/{$_GET["page"]}.md"));
$yml = $pg->getYAML();
$PageTitle = $yml['title'];
require_once '/var/www/tilde/server/header2.php';?>
<a href=".">&lt; news</a>
<p><?=$yml["date"]?> | <a href="/~<?=$yml["author"]?>/">~<?=$yml["author"]?></a></p>
<hr />
<?=$pg->getContent()?>
<?php }
require_once '/var/www/tilde/server/footer.php' ?>

36
news/json2mb.rb Normal file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env ruby
require 'yaml'
require 'json'
require 'optparse'
require 'ostruct'
require 'fileutils'
#quit unless our script gets two command line arguments
unless ARGV.length == 3
puts "Dude, not the right number of arguments."
puts "Usage: ruby json2md.rb [-j][-y] json_file.json yaml_file.yaml\n"
exit
end
$json_file = ARGV[1]
$yaml_file = ARGV[2]
options = OpenStruct.new
OptionParser.new do |opt|
opt.on('-j', '--json', 'Convert to JSON') { |o| options.json = o }
opt.on('-y', '--yaml', 'Convert to YAML') { |o| options.yaml = o }
end.parse!
case
when options.yaml == true
y_file = File.open("#{$yaml_file}", 'a')
y_file.write(YAML.dump(JSON.parse(IO.read($json_file))))
y_file.close
puts "Converted to YAML. Output file is #{$yaml_file}"
when options.json == true
j_file = YAML.load_file(File.open("#{$yaml_file}", 'r'))
File.write "#{$json_file}", JSON.pretty_generate(j_file)
puts "Converted to JSON. Output file is #{$json_file}"
end

View File

@ -0,0 +1,21 @@
---
published: true
date: February 28, 2020
title: Welcome to summit pubnix!
author: anton
---
Welcome to summit pubnix!
summit is an intentional and inclusive community for developing, making, learning, teaching, socializing, and enjoying various aspects of GNU/Linux in a free/non-commercial environment. If you need help or have any questions, feel free to ask in [#pubnix](https://web.tilde.chat/?join=pubnix) on irc.tilde.chat.
summit tries to adhere to the values and philosophy of the Hacker Ethic whenever possible. The hacker ethics and beliefs as described by Levy are:
- Access to computers - and anything which might teach you something about the way the world works - should be unlimited and total. Always yield to the Hands-On Imperative!
- All information should be free
- Mistrust authority - promote decentralization
- Hackers should be judged by their hacking, not criteria such as degrees, age, race, sex, or position
- You can create art and beauty on a computer
- Computers can change your life for the better
Have fun, and thanks for being a part of the summit pubnix community!

8
news/pages/TEMPLATE Normal file
View File

@ -0,0 +1,8 @@
---
published: false
date: January 1, 1980
title: Title
author: anton
---
Content

34
server/footer.php Normal file
View File

@ -0,0 +1,34 @@
</section>
</div>
</div>
<footer class="footer">
<div class="footer-container">
<div class="footer-container-item">
<h1>Links</h1>
<p><a class="td-none" href="/join">Join</a></p>
<p><a class="td-none" href="/faq">FAQ</a></p>
<p><a class="td-none" href="/contact">Contact</a></p>
<p><a class="td-none" href="/wiki">Wiki</a></p>
</div>
<div class="footer-container-item">
<h1>Resources</h1>
<p><a class="td-none" href="https://www.antonmcclure.com">AntonMcClure.com</a></p>
<p><a class="td-none" href="https://www.antonmcclure.com/fighting-for-justice">Fighting for Justice</a></p>
<p><a class="td-none" href="https://www.antonmcclure.com/covid-19">COVID-19</a></p>
<p><a class="td-none" href="https://www.antonmcclure.com/irc">IRC</a></p>
</div>
<div class="footer-container-item">
<h1>Legal</h1>
<p><a class="td-none" href="https://www.antonmcclure.com/legal/summit-terms">Terms of Use</a></p>
<p><a class="td-none" href="https://www.antonmcclure.com/legal/summit-privacy">Privacy Policy</a></p>
<p><a class="td-none" href="https://www.antonmcclure.com/legal/summit-conduct">Code of Conduct</a></p>
<p><a class="td-none" href="https://www.antonmcclure.com/legal/summit-tildeverse">Tildeverse Policy</a></p>
</div>
</div>
<div class="footer-txt">
<div class="copyright">
Copyright &copy; 2019-<?=date("Y")?>, Anton McClure. All Rights Reserved.</div>
</div>
</footer>
</body>
</html>

14
server/header1.php Normal file
View File

@ -0,0 +1,14 @@
<?php
//error_reporting(-1); ini_set("display_errors", "1"); ini_set("log_errors", 1); ini_set("error_log", "/tmp/php-error.log");
require '/var/www/tilde/vendor/autoload.php';
$parser = Tildeverse\Wiki\Parser::factory();
$SiteName = "Summit Pubnix";
$SiteCopyrightFrom = "2018";
$SiteCopyrightTo = (int)date('Y');
$SiteCopyrightHolder = "Anton McClure";
$ProgCopyrightFrom = "2018";
$ProgCopyrightTo = $SiteCopyrightTo;
$SiteDomain = $_SERVER['HTTP_HOST'];
$SiteRequestURI = $_SERVER['REQUEST_URI'];
$PageURL = "https://$SiteDomain{$_SERVER['REQUEST_URI']}";
?>

29
server/header2.php Normal file
View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html itemscope itemtype="http://schema.org/WebPage" lang="en">
<meta charset="utf-8">
<script src="https://assets.antonmcclure.com/js/fa-all.min.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://assets.antonmcclure.com/amcclure752595.css">
<meta name="author" content="Anton McClure">
<link rel="canonical" href="<?=$PageURL?>" />
<title><?=$SiteName?> | <?=$PageTitle?></title>
<meta name="title" content="<?=$PageTitle?>">
<meta name="author" contents="<?=$PageAuthor?>">
</head>
<body>
<header>
<div class="header">
<span class="site-title"><a title="Home Page" class="h-card tc-td-none" href="https://summit.tildex.com">Summit Pubnix</a></span>
</div>
<nav class="navbar">
<ul>
<li><a href="/join"><strong>Join</strong></a></li>
<li><a href="/faq"><strong>FAQ</strong></a></li>
<li><a href="//tildeverse.org"><strong>Tildeverse</strong></a></li>
<li><a href="/contact"><strong>Contact</strong></a></li>
<li><a href="/wiki"><strong>Wiki</strong></a></li>
</nav>
</header>
<div class="row border">
<div class="main">
<section class="content">
<h1 class="page-title center"><?=$PageTitle?></h1>

56
server/mcclure.css Normal file
View File

@ -0,0 +1,56 @@
/* mcclure.css
* Copyright (C) 2019, Anton McClure.
*
* mcclure.css by Anton McClure is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
*/
html {
background: #e4e4e4;
margin: 0px 0px 0px 0px;
}
div.page {
max-width: 70em;
margin: auto;
background-color: white;
border: .1em solid #bbb;
box-shadow: 0 0 4px 4px #bbb
}
div.header {
text-align: center;
}
div.footer {
text-align: center;
}
span.name1 {
color: black;
}
span.name2 {
color: black;
}
hr {
display: block;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: 0em;
margin-right: 0em;
border-width: 2px;
}
div.content {
padding: 0px 20px 0px 20px;
}
div.banners {
text-align: center;
}
table, th, td { padding: 3px;
}
ul {
display: flex;
flex-direction: column;
flex-wrap: wrap;
}
div.message {
outline: 2px;
border-style: solid;
padding: 6px;
}

5
template/page.php Normal file
View File

@ -0,0 +1,5 @@
<?php require_once '/var/www/tilde/server/header1.php'
echo("Page";
require_once '/var/www/tilde/server/header2.php' ?>
<p>Coming soon...</p>
<?php require_once '/var/www/tilde/server/footer.php' ?>

97
tildegit.php Normal file
View File

@ -0,0 +1,97 @@
<?php
/*
* Original code by Gregor Aisch (gka) <https://github.com/gka>
*
* https://gist.github.com/gka/4627519
*
*/
/*
* Endpoint for Github Webhook URLs
*
* see: https://help.github.com/articles/post-receive-hooks
*
*/
// script errors will be send to this email:
$error_mail = "root@summit.tildex.com";
function run() {
global $rawInput;
// read config.json
$config_filename = 'config.json';
if (!file_exists($config_filename)) {
throw new Exception("Can't find ".$config_filename);
}
$config = json_decode(file_get_contents($config_filename), true);
$postBody = $_POST['payload'];
$payload = json_decode($postBody);
if (isset($config['email'])) {
$headers = 'From: '.$config['email']['from']."\r\n";
$headers .= 'CC: ' . $payload->pusher->email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
}
// check if the request comes from tildegit server
$tildegit_ips = array('167.114.7.65');
if (in_array($_SERVER['REMOTE_ADDR'], $tildegit_ips)) {
foreach ($config['endpoints'] as $endpoint) {
// check if the push came from the right repository and branch
if ($payload->repository->url == 'https://tildegit.com/' . $endpoint['repo']
&& $payload->ref == 'refs/heads/' . $endpoint['branch']) {
// execute update script, and record its output
ob_start();
passthru($endpoint['run']);
$output = ob_end_contents();
// prepare and send the notification email
if (isset($config['email'])) {
// send mail to someone, and the tildegit user who pushed the commit
$body = '<p>The tildegit user <a href="https://tildegit.com/'
. $payload->pusher->name .'">@' . $payload->pusher->name . '</a>'
. ' has pushed to ' . $payload->repository->url
. ' and consequently, ' . $endpoint['action']
. '.</p>';
$body .= '<p>Here\'s a brief list of what has been changed:</p>';
$body .= '<ul>';
foreach ($payload->commits as $commit) {
$body .= '<li>'.$commit->message.'<br />';
$body .= '<small style="color:#999">added: <b>'.count($commit->added)
.'</b> &nbsp; modified: <b>'.count($commit->modified)
.'</b> &nbsp; removed: <b>'.count($commit->removed)
.'</b> &nbsp; <a href="' . $commit->url
. '">read more</a></small></li>';
}
$body .= '</ul>';
$body .= '<p>What follows is the output of the script:</p><pre>';
$body .= $output. '</pre>';
$body .= '<p>Cheers, <br/>tildegit Webhook Endpoint</p>';
mail($config['email']['to'], $endpoint['action'], $body, $headers);
}
return true;
}
}
} else {
throw new Exception("This does not appear to be a valid requests from tildegit.\n");
}
}
try {
if (!isset($_POST['payload'])) {
echo "Works fine.";
echo shell_exec("cd /var/www/tilde && /usr/bin/git reset --hard && /usr/bin/git pull origin master 2>&1 && chown -Rv www-data:www-data /var/www/tilde/");
} else {
run();
}
} catch ( Exception $e ) {
$msg = $e->getMessage();
mail($error_mail, $msg, ''.$e);
}

7
vendor/autoload.php vendored Normal file
View File

@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitbc340f150b580692047f2c15e42caf19::getLoader();

445
vendor/composer/ClassLoader.php vendored Normal file
View File

@ -0,0 +1,445 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath.'\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

56
vendor/composer/LICENSE vendored Normal file
View File

@ -0,0 +1,56 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Composer
Upstream-Contact: Jordi Boggiano <j.boggiano@seld.be>
Source: https://github.com/composer/composer
Files: *
Copyright: 2016, Nils Adermann <naderman@naderman.de>
2016, Jordi Boggiano <j.boggiano@seld.be>
License: Expat
Files: src/Composer/Util/TlsHelper.php
Copyright: 2016, Nils Adermann <naderman@naderman.de>
2016, Jordi Boggiano <j.boggiano@seld.be>
2013, Evan Coury <me@evancoury.com>
License: Expat and BSD-2-Clause
License: BSD-2-Clause
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
.
* 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.
.
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 OWNER 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.
License: Expat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

9
vendor/composer/autoload_classmap.php vendored Normal file
View File

@ -0,0 +1,9 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

10
vendor/composer/autoload_files.php vendored Normal file
View File

@ -0,0 +1,10 @@
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
);

11
vendor/composer/autoload_namespaces.php vendored Normal file
View File

@ -0,0 +1,11 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'ParsedownExtra' => array($vendorDir . '/erusev/parsedown-extra'),
'Parsedown' => array($vendorDir . '/erusev/parsedown'),
);

13
vendor/composer/autoload_psr4.php vendored Normal file
View File

@ -0,0 +1,13 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Tildeverse\\Wiki\\' => array($vendorDir . '/tildeverse/wiki/src'),
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'),
'Mni\\FrontYAML\\' => array($vendorDir . '/mnapoli/front-yaml/src'),
);

70
vendor/composer/autoload_real.php vendored Normal file
View File

@ -0,0 +1,70 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitbc340f150b580692047f2c15e42caf19
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitbc340f150b580692047f2c15e42caf19', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitbc340f150b580692047f2c15e42caf19', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitbc340f150b580692047f2c15e42caf19::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitbc340f150b580692047f2c15e42caf19::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequirebc340f150b580692047f2c15e42caf19($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequirebc340f150b580692047f2c15e42caf19($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}

71
vendor/composer/autoload_static.php vendored Normal file
View File

@ -0,0 +1,71 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInitbc340f150b580692047f2c15e42caf19
{
public static $files = array (
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
);
public static $prefixLengthsPsr4 = array (
'T' =>
array (
'Tildeverse\\Wiki\\' => 16,
),
'S' =>
array (
'Symfony\\Polyfill\\Ctype\\' => 23,
'Symfony\\Component\\Yaml\\' => 23,
),
'M' =>
array (
'Mni\\FrontYAML\\' => 14,
),
);
public static $prefixDirsPsr4 = array (
'Tildeverse\\Wiki\\' =>
array (
0 => __DIR__ . '/..' . '/tildeverse/wiki/src',
),
'Symfony\\Polyfill\\Ctype\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
),
'Symfony\\Component\\Yaml\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/yaml',
),
'Mni\\FrontYAML\\' =>
array (
0 => __DIR__ . '/..' . '/mnapoli/front-yaml/src',
),
);
public static $prefixesPsr0 = array (
'P' =>
array (
'ParsedownExtra' =>
array (
0 => __DIR__ . '/..' . '/erusev/parsedown-extra',
),
'Parsedown' =>
array (
0 => __DIR__ . '/..' . '/erusev/parsedown',
),
),
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitbc340f150b580692047f2c15e42caf19::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitbc340f150b580692047f2c15e42caf19::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInitbc340f150b580692047f2c15e42caf19::$prefixesPsr0;
}, null, ClassLoader::class);
}
}

286
vendor/composer/installed.json vendored Normal file
View File

@ -0,0 +1,286 @@
[
{
"name": "erusev/parsedown",
"version": "1.7.4",
"version_normalized": "1.7.4.0",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown.git",
"reference": "cb17b6477dfff935958ba01325f2e8a2bfa6dab3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/cb17b6477dfff935958ba01325f2e8a2bfa6dab3",
"reference": "cb17b6477dfff935958ba01325f2e8a2bfa6dab3",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
},
"time": "2019-12-30T22:54:17+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"Parsedown": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "Parser for Markdown.",
"homepage": "http://parsedown.org",
"keywords": [
"markdown",
"parser"
]
},
{
"name": "erusev/parsedown-extra",
"version": "0.7.1",
"version_normalized": "0.7.1.0",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown-extra.git",
"reference": "0db5cce7354e4b76f155d092ab5eb3981c21258c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown-extra/zipball/0db5cce7354e4b76f155d092ab5eb3981c21258c",
"reference": "0db5cce7354e4b76f155d092ab5eb3981c21258c",
"shasum": ""
},
"require": {
"erusev/parsedown": "~1.4"
},
"time": "2015-11-01T10:19:22+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"ParsedownExtra": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "An extension of Parsedown that adds support for Markdown Extra.",
"homepage": "https://github.com/erusev/parsedown-extra",
"keywords": [
"markdown",
"markdown extra",
"parsedown",
"parser"
]
},
{
"name": "mnapoli/front-yaml",
"version": "1.6.0",
"version_normalized": "1.6.0.0",
"source": {
"type": "git",
"url": "https://github.com/mnapoli/FrontYAML.git",
"reference": "24070ace8b741247bb3161cbb38ecc541268b296"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mnapoli/FrontYAML/zipball/24070ace8b741247bb3161cbb38ecc541268b296",
"reference": "24070ace8b741247bb3161cbb38ecc541268b296",
"shasum": ""
},
"require": {
"erusev/parsedown": "~1.0",
"php": ">=5.4.0",
"symfony/yaml": "~2.1|^3.0|^4.0"
},
"require-dev": {
"league/commonmark": "~0.7",
"phpunit/phpunit": "~4.5"
},
"time": "2017-10-29T19:29:55+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Mni\\FrontYAML\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
]
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.14.0",
"version_normalized": "1.14.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38",
"reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"time": "2020-01-13T11:15:53+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.14-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
]
},
{
"name": "symfony/yaml",
"version": "v4.4.4",
"version_normalized": "4.4.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "cd014e425b3668220adb865f53bff64b3ad21767"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/cd014e425b3668220adb865f53bff64b3ad21767",
"reference": "cd014e425b3668220adb865f53bff64b3ad21767",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/polyfill-ctype": "~1.8"
},
"conflict": {
"symfony/console": "<3.4"
},
"require-dev": {
"symfony/console": "^3.4|^4.0|^5.0"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
},
"time": "2020-01-21T11:12:16+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com"
},
{
"name": "tildeverse/wiki",
"version": "dev-master",
"version_normalized": "9999999-dev",
"source": {
"type": "git",
"url": "https://tildegit.org/ben/tildewiki",
"reference": "751eb64c383cb7c6ec643eaf683b88aa1de351ea"
},
"require": {
"erusev/parsedown-extra": "^0.7.1",
"mnapoli/front-yaml": "^1.6"
},
"time": "2019-07-03T05:06:34+00:00",
"type": "library",
"installation-source": "source",
"autoload": {
"psr-4": {
"Tildeverse\\Wiki\\": "src/"
}
},
"license": [
"GPLv3"
],
"authors": [
{
"name": "Ben Harris",
"email": "ben@tilde.team"
}
],
"description": "parsedown extensions for tilde wikis"
}
]

View File

@ -0,0 +1,11 @@
language: php
php:
- 5.6
- 5.5
- 5.4
- 5.3
install:
- composer self-update
- composer install

View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Emanuil Rusev, erusev.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,526 @@
<?php
#
#
# Parsedown Extra
# https://github.com/erusev/parsedown-extra
#
# (c) Emanuil Rusev
# http://erusev.com
#
# For the full license information, view the LICENSE file that was distributed
# with this source code.
#
#
class ParsedownExtra extends Parsedown
{
# ~
const version = '0.7.0';
# ~
function __construct()
{
if (parent::version < '1.5.0')
{
throw new Exception('ParsedownExtra requires a later version of Parsedown');
}
$this->BlockTypes[':'] []= 'DefinitionList';
$this->BlockTypes['*'] []= 'Abbreviation';
# identify footnote definitions before reference definitions
array_unshift($this->BlockTypes['['], 'Footnote');
# identify footnote markers before before links
array_unshift($this->InlineTypes['['], 'FootnoteMarker');
}
#
# ~
function text($text)
{
$markup = parent::text($text);
# merge consecutive dl elements
$markup = preg_replace('/<\/dl>\s+<dl>\s+/', '', $markup);
# add footnotes
if (isset($this->DefinitionData['Footnote']))
{
$Element = $this->buildFootnoteElement();
$markup .= "\n" . $this->element($Element);
}
return $markup;
}
#
# Blocks
#
#
# Abbreviation
protected function blockAbbreviation($Line)
{
if (preg_match('/^\*\[(.+?)\]:[ ]*(.+?)[ ]*$/', $Line['text'], $matches))
{
$this->DefinitionData['Abbreviation'][$matches[1]] = $matches[2];
$Block = array(
'hidden' => true,
);
return $Block;
}
}
#
# Footnote
protected function blockFootnote($Line)
{
if (preg_match('/^\[\^(.+?)\]:[ ]?(.*)$/', $Line['text'], $matches))
{
$Block = array(
'label' => $matches[1],
'text' => $matches[2],
'hidden' => true,
);
return $Block;
}
}
protected function blockFootnoteContinue($Line, $Block)
{
if ($Line['text'][0] === '[' and preg_match('/^\[\^(.+?)\]:/', $Line['text']))
{
return;
}
if (isset($Block['interrupted']))
{
if ($Line['indent'] >= 4)
{
$Block['text'] .= "\n\n" . $Line['text'];
return $Block;
}
}
else
{
$Block['text'] .= "\n" . $Line['text'];
return $Block;
}
}
protected function blockFootnoteComplete($Block)
{
$this->DefinitionData['Footnote'][$Block['label']] = array(
'text' => $Block['text'],
'count' => null,
'number' => null,
);
return $Block;
}
#
# Definition List
protected function blockDefinitionList($Line, $Block)
{
if ( ! isset($Block) or isset($Block['type']))
{
return;
}
$Element = array(
'name' => 'dl',
'handler' => 'elements',
'text' => array(),
);
$terms = explode("\n", $Block['element']['text']);
foreach ($terms as $term)
{
$Element['text'] []= array(
'name' => 'dt',
'handler' => 'line',
'text' => $term,
);
}
$Block['element'] = $Element;
$Block = $this->addDdElement($Line, $Block);
return $Block;
}
protected function blockDefinitionListContinue($Line, array $Block)
{
if ($Line['text'][0] === ':')
{
$Block = $this->addDdElement($Line, $Block);
return $Block;
}
else
{
if (isset($Block['interrupted']) and $Line['indent'] === 0)
{
return;
}
if (isset($Block['interrupted']))
{
$Block['dd']['handler'] = 'text';
$Block['dd']['text'] .= "\n\n";
unset($Block['interrupted']);
}
$text = substr($Line['body'], min($Line['indent'], 4));
$Block['dd']['text'] .= "\n" . $text;
return $Block;
}
}
#
# Header
protected function blockHeader($Line)
{
$Block = parent::blockHeader($Line);
if (preg_match('/[ #]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
{
$attributeString = $matches[1][0];
$Block['element']['attributes'] = $this->parseAttributeData($attributeString);
$Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]);
}
return $Block;
}
#
# Markup
protected function blockMarkupComplete($Block)
{
if ( ! isset($Block['void']))
{
$Block['markup'] = $this->processTag($Block['markup']);
}
return $Block;
}
#
# Setext
protected function blockSetextHeader($Line, array $Block = null)
{
$Block = parent::blockSetextHeader($Line, $Block);
if (preg_match('/[ ]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
{
$attributeString = $matches[1][0];
$Block['element']['attributes'] = $this->parseAttributeData($attributeString);
$Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]);
}
return $Block;
}
#
# Inline Elements
#
#
# Footnote Marker
protected function inlineFootnoteMarker($Excerpt)
{
if (preg_match('/^\[\^(.+?)\]/', $Excerpt['text'], $matches))
{
$name = $matches[1];
if ( ! isset($this->DefinitionData['Footnote'][$name]))
{
return;
}
$this->DefinitionData['Footnote'][$name]['count'] ++;
if ( ! isset($this->DefinitionData['Footnote'][$name]['number']))
{
$this->DefinitionData['Footnote'][$name]['number'] = ++ $this->footnoteCount; # » &
}
$Element = array(
'name' => 'sup',
'attributes' => array('id' => 'fnref'.$this->DefinitionData['Footnote'][$name]['count'].':'.$name),
'handler' => 'element',
'text' => array(
'name' => 'a',
'attributes' => array('href' => '#fn:'.$name, 'class' => 'footnote-ref'),
'text' => $this->DefinitionData['Footnote'][$name]['number'],
),
);
return array(
'extent' => strlen($matches[0]),
'element' => $Element,
);
}
}
private $footnoteCount = 0;
#
# Link
protected function inlineLink($Excerpt)
{
$Link = parent::inlineLink($Excerpt);
$remainder = substr($Excerpt['text'], $Link['extent']);
if (preg_match('/^[ ]*{('.$this->regexAttribute.'+)}/', $remainder, $matches))
{
$Link['element']['attributes'] += $this->parseAttributeData($matches[1]);
$Link['extent'] += strlen($matches[0]);
}
return $Link;
}
#
# ~
#
protected function unmarkedText($text)
{
$text = parent::unmarkedText($text);
if (isset($this->DefinitionData['Abbreviation']))
{
foreach ($this->DefinitionData['Abbreviation'] as $abbreviation => $meaning)
{
$pattern = '/\b'.preg_quote($abbreviation, '/').'\b/';
$text = preg_replace($pattern, '<abbr title="'.$meaning.'">'.$abbreviation.'</abbr>', $text);
}
}
return $text;
}
#
# Util Methods
#
protected function addDdElement(array $Line, array $Block)
{
$text = substr($Line['text'], 1);
$text = trim($text);
unset($Block['dd']);
$Block['dd'] = array(
'name' => 'dd',
'handler' => 'line',
'text' => $text,
);
if (isset($Block['interrupted']))
{
$Block['dd']['handler'] = 'text';
unset($Block['interrupted']);
}
$Block['element']['text'] []= & $Block['dd'];
return $Block;
}
protected function buildFootnoteElement()
{
$Element = array(
'name' => 'div',
'attributes' => array('class' => 'footnotes'),
'handler' => 'elements',
'text' => array(
array(
'name' => 'hr',
),
array(
'name' => 'ol',
'handler' => 'elements',
'text' => array(),
),
),
);
uasort($this->DefinitionData['Footnote'], 'self::sortFootnotes');
foreach ($this->DefinitionData['Footnote'] as $definitionId => $DefinitionData)
{
if ( ! isset($DefinitionData['number']))
{
continue;
}
$text = $DefinitionData['text'];
$text = parent::text($text);
$numbers = range(1, $DefinitionData['count']);
$backLinksMarkup = '';
foreach ($numbers as $number)
{
$backLinksMarkup .= ' <a href="#fnref'.$number.':'.$definitionId.'" rev="footnote" class="footnote-backref">&#8617;</a>';
}
$backLinksMarkup = substr($backLinksMarkup, 1);
if (substr($text, - 4) === '</p>')
{
$backLinksMarkup = '&#160;'.$backLinksMarkup;
$text = substr_replace($text, $backLinksMarkup.'</p>', - 4);
}
else
{
$text .= "\n".'<p>'.$backLinksMarkup.'</p>';
}
$Element['text'][1]['text'] []= array(
'name' => 'li',
'attributes' => array('id' => 'fn:'.$definitionId),
'text' => "\n".$text."\n",
);
}
return $Element;
}
# ~
protected function parseAttributeData($attributeString)
{
$Data = array();
$attributes = preg_split('/[ ]+/', $attributeString, - 1, PREG_SPLIT_NO_EMPTY);
foreach ($attributes as $attribute)
{
if ($attribute[0] === '#')
{
$Data['id'] = substr($attribute, 1);
}
else # "."
{
$classes []= substr($attribute, 1);
}
}
if (isset($classes))
{
$Data['class'] = implode(' ', $classes);
}
return $Data;
}
# ~
protected function processTag($elementMarkup) # recursive
{
# http://stackoverflow.com/q/1148928/200145
libxml_use_internal_errors(true);
$DOMDocument = new DOMDocument;
# http://stackoverflow.com/q/11309194/200145
$elementMarkup = mb_convert_encoding($elementMarkup, 'HTML-ENTITIES', 'UTF-8');
# http://stackoverflow.com/q/4879946/200145
$DOMDocument->loadHTML($elementMarkup);
$DOMDocument->removeChild($DOMDocument->doctype);
$DOMDocument->replaceChild($DOMDocument->firstChild->firstChild->firstChild, $DOMDocument->firstChild);
$elementText = '';
if ($DOMDocument->documentElement->getAttribute('markdown') === '1')
{
foreach ($DOMDocument->documentElement->childNodes as $Node)
{
$elementText .= $DOMDocument->saveHTML($Node);
}
$DOMDocument->documentElement->removeAttribute('markdown');
$elementText = "\n".$this->text($elementText)."\n";
}
else
{
foreach ($DOMDocument->documentElement->childNodes as $Node)
{
$nodeMarkup = $DOMDocument->saveHTML($Node);
if ($Node instanceof DOMElement and ! in_array($Node->nodeName, $this->textLevelElements))
{
$elementText .= $this->processTag($nodeMarkup);
}
else
{
$elementText .= $nodeMarkup;
}
}
}
# because we don't want for markup to get encoded
$DOMDocument->documentElement->nodeValue = 'placeholder\x1A';
$markup = $DOMDocument->saveHTML($DOMDocument->documentElement);
$markup = str_replace('placeholder\x1A', $elementText, $markup);
return $markup;
}
# ~
protected function sortFootnotes($A, $B) # callback
{
return $A['number'] - $B['number'];
}
#
# Fields
#
protected $regexAttribute = '(?:[#.][-\w]+[ ]*)';
}

31
vendor/erusev/parsedown-extra/README.md vendored Normal file
View File

@ -0,0 +1,31 @@
> You might also like [Caret](http://caret.io?ref=parsedown) - our Markdown editor for the Desktop.
## Parsedown Extra
[![Build Status](https://img.shields.io/travis/erusev/parsedown-extra/master.svg?style=flat-square)](https://travis-ci.org/erusev/parsedown-extra)
An extension of [Parsedown](http://parsedown.org) that adds support for [Markdown Extra](https://michelf.ca/projects/php-markdown/extra/).
[See Demo](http://parsedown.org/extra/)
### Installation
Include both `Parsedown.php` and `ParsedownExtra.php` or install [the composer package](https://packagist.org/packages/erusev/parsedown-extra).
### Example
``` php
$Extra = new ParsedownExtra();
echo $Extra->text('# Header {.sth}'); # prints: <h1 class="sth">Header</h1>
```
### Questions
**Who uses Parsedown Extra?**
[October CMS](http://octobercms.com/), [Bolt CMS](http://bolt.cm/), [Kirby CMS](http://getkirby.com/), [Grav CMS](http://getgrav.org/), [Statamic CMS](http://www.statamic.com/) and [more](https://www.versioneye.com/php/erusev:parsedown-extra/references).
**How can I help?**
Use it, star it, share it and in case you feel generous, [donate some money](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=528P3NZQMP8N2).

View File

@ -0,0 +1,21 @@
{
"name": "erusev/parsedown-extra",
"description": "An extension of Parsedown that adds support for Markdown Extra.",
"keywords": ["markdown", "markdown extra", "parser", "parsedown"],
"homepage": "https://github.com/erusev/parsedown-extra",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"require": {
"erusev/parsedown": "~1.4"
},
"autoload": {
"psr-0": {"ParsedownExtra": ""}
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="test/bootstrap.php" colors="true">
<testsuites>
<testsuite>
<file>test/ParsedownExtraTest.php</file>
</testsuite>
</testsuites>
</phpunit>

View File

@ -0,0 +1,20 @@
<?php
class ParsedownExtraTest extends ParsedownTest
{
protected function initDirs()
{
$dirs = parent::initDirs();
$dirs []= dirname(__FILE__).'/data/';
return $dirs;
}
protected function initParsedown()
{
$Parsedown = new ParsedownExtra();
return $Parsedown;
}
}

View File

@ -0,0 +1,10 @@
<?php
$dir = file_exists('../parsedown/')
? '../parsedown/' # child
: 'vendor/erusev/parsedown/'; # parent
include $dir . 'Parsedown.php';
include $dir . 'test/ParsedownTest.php';
include 'ParsedownExtra.php';

View File

@ -0,0 +1,3 @@
<p>The <abbr title="Hyper Text Markup Language">HTML</abbr> specification
is maintained by the <abbr title="World Wide Web Consortium">W3C</abbr>.
The abbreviation <abbr title="Markup Language">ML</abbr> is contained in the abbreviation <abbr title="Hyper Text Markup Language">HTML</abbr>.</p>

View File

@ -0,0 +1,7 @@
The HTML specification
is maintained by the W3C.
The abbreviation ML is contained in the abbreviation HTML.
*[HTML]: Hyper Text Markup Language
*[W3C]: World Wide Web Consortium
*[ML]: Markup Language

View File

@ -0,0 +1,18 @@
<p>footnote <sup id="fnref1:1"><a href="#fn:1" class="footnote-ref">1</a></sup> and another one <sup id="fnref1:2"><a href="#fn:2" class="footnote-ref">2</a></sup></p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
<p>line 1
line 2</p>
<blockquote>
<p>quote</p>
</blockquote>
<p>another paragraph&#160;<a href="#fnref1:1" rev="footnote" class="footnote-backref">&#8617;</a></p>
</li>
<li id="fn:2">
<p>paragraph</p>
<p>another paragraph&#160;<a href="#fnref1:2" rev="footnote" class="footnote-backref">&#8617;</a></p>
</li>
</ol>
</div>

View File

@ -0,0 +1,14 @@
footnote [^1] and another one [^2]
[^1]: line 1
line 2
> quote
another paragraph
[^2]:
paragraph
another paragraph

View File

@ -0,0 +1,17 @@
<dl>
<dt>Term 1</dt>
<dd>one</dd>
<dd>two
extra line</dd>
<dt>Term 2</dt>
<dd><p>lazy
line</p></dd>
<dd><p>multiple</p>
<p>paragraphs</p></dd>
<dd><p>nested</p>
<pre><code>code block</code></pre>
<blockquote>
<p>quote
block</p>
</blockquote></dd>
</dl>

View File

@ -0,0 +1,20 @@
Term 1
: one
: two
extra line
Term 2
: lazy
line
: multiple
paragraphs
: nested
code block
> quote
> block

View File

@ -0,0 +1,20 @@
<p>first <sup id="fnref1:1"><a href="#fn:1" class="footnote-ref">1</a></sup> second <sup id="fnref1:2"><a href="#fn:2" class="footnote-ref">2</a></sup>.</p>
<p>first <sup id="fnref1:a"><a href="#fn:a" class="footnote-ref">3</a></sup> second <sup id="fnref1:b"><a href="#fn:b" class="footnote-ref">4</a></sup>.</p>
<p>second time <sup id="fnref2:1"><a href="#fn:1" class="footnote-ref">1</a></sup></p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
<p>one&#160;<a href="#fnref1:1" rev="footnote" class="footnote-backref">&#8617;</a> <a href="#fnref2:1" rev="footnote" class="footnote-backref">&#8617;</a></p>
</li>
<li id="fn:2">
<p>two&#160;<a href="#fnref1:2" rev="footnote" class="footnote-backref">&#8617;</a></p>
</li>
<li id="fn:a">
<p>one&#160;<a href="#fnref1:a" rev="footnote" class="footnote-backref">&#8617;</a></p>
</li>
<li id="fn:b">
<p>two&#160;<a href="#fnref1:b" rev="footnote" class="footnote-backref">&#8617;</a></p>
</li>
</ol>
</div>

View File

@ -0,0 +1,11 @@
first [^1] second [^2].
[^1]: one
[^2]: two
first [^a] second [^b].
[^a]: one
[^b]: two
second time [^1]

View File

@ -0,0 +1,25 @@
<div class="example">
<p><em>markdown</em></p>
<p>This is another paragraph. It contains <em>inline markup</em>.</p>
<div>
_no markdown_
</div>
</div>
<hr />
<div>
<p><em>markdown</em></p>
<div>
<p><em>markdown</em></p>
</div>
</div>
<hr />
<div>
_no markdown_
<div>
<p><em>markdown</em></p>
</div>
</div>
<hr />
<div markdown="0">
_no markdown_
</div>

View File

@ -0,0 +1,32 @@
<div class="example" markdown="1">
_markdown_
This is another paragraph. It contains <em>inline markup</em>.
<div>
_no markdown_
</div>
</div>
---
<div markdown="1">
_markdown_
<div markdown="1">
_markdown_
</div>
</div>
---
<div>
_no markdown_
<div markdown="1">
_markdown_
</div>
</div>
---
<div markdown="0">
_no markdown_
</div>

View File

@ -0,0 +1,6 @@
<h1 id="header1">Header 1</h1>
<h2 id="header2">Header 2</h2>
<h2 class="main">The Site</h2>
<h2 id="the-site" class="main shine">The Site</h2>
<p><a href="http://parsedown.org" id="link" class="primary upper-case">link</a></p>
<p><img src="/md.png" alt="logo" id="logo" class="big" /></p>

View File

@ -0,0 +1,12 @@
Header 1 {#header1}
========
## Header 2 ## {#header2}
## The Site ## {.main}
## The Site ## {.main .shine #the-site}
[link](http://parsedown.org) {.primary #link .upper-case}
![logo](/md.png) {#logo .big}

20
vendor/erusev/parsedown/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013-2018 Emanuil Rusev, erusev.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1712
vendor/erusev/parsedown/Parsedown.php vendored Normal file

File diff suppressed because it is too large Load Diff

86
vendor/erusev/parsedown/README.md vendored Normal file
View File

@ -0,0 +1,86 @@
> I also make [Caret](https://caret.io?ref=parsedown) - a Markdown editor for Mac and PC.
## Parsedown
[![Build Status](https://img.shields.io/travis/erusev/parsedown/master.svg?style=flat-square)](https://travis-ci.org/erusev/parsedown)
<!--[![Total Downloads](http://img.shields.io/packagist/dt/erusev/parsedown.svg?style=flat-square)](https://packagist.org/packages/erusev/parsedown)-->
Better Markdown Parser in PHP
[Demo](http://parsedown.org/demo) |
[Benchmarks](http://parsedown.org/speed) |
[Tests](http://parsedown.org/tests/) |
[Documentation](https://github.com/erusev/parsedown/wiki/)
### Features
* One File
* No Dependencies
* Super Fast
* Extensible
* [GitHub flavored](https://help.github.com/articles/github-flavored-markdown)
* Tested in 5.3 to 7.1 and in HHVM
* [Markdown Extra extension](https://github.com/erusev/parsedown-extra)
### Installation
Include `Parsedown.php` or install [the composer package](https://packagist.org/packages/erusev/parsedown).
### Example
``` php
$Parsedown = new Parsedown();
echo $Parsedown->text('Hello _Parsedown_!'); # prints: <p>Hello <em>Parsedown</em>!</p>
```
More examples in [the wiki](https://github.com/erusev/parsedown/wiki/) and in [this video tutorial](http://youtu.be/wYZBY8DEikI).
### Security
Parsedown is capable of escaping user-input within the HTML that it generates. Additionally Parsedown will apply sanitisation to additional scripting vectors (such as scripting link destinations) that are introduced by the markdown syntax itself.
To tell Parsedown that it is processing untrusted user-input, use the following:
```php
$parsedown = new Parsedown;
$parsedown->setSafeMode(true);
```
If instead, you wish to allow HTML within untrusted user-input, but still want output to be free from XSS it is recommended that you make use of a HTML sanitiser that allows HTML tags to be whitelisted, like [HTML Purifier](http://htmlpurifier.org/).
In both cases you should strongly consider employing defence-in-depth measures, like [deploying a Content-Security-Policy](https://scotthelme.co.uk/content-security-policy-an-introduction/) (a browser security feature) so that your page is likely to be safe even if an attacker finds a vulnerability in one of the first lines of defence above.
#### Security of Parsedown Extensions
Safe mode does not necessarily yield safe results when using extensions to Parsedown. Extensions should be evaluated on their own to determine their specific safety against XSS.
### Escaping HTML
> ⚠️  **WARNING:** This method isn't safe from XSS!
If you wish to escape HTML **in trusted input**, you can use the following:
```php
$parsedown = new Parsedown;
$parsedown->setMarkupEscaped(true);
```
Beware that this still allows users to insert unsafe scripting vectors, such as links like `[xss](javascript:alert%281%29)`.
### Questions
**How does Parsedown work?**
It tries to read Markdown like a human. First, it looks at the lines. Its interested in how the lines start. This helps it recognise blocks. It knows, for example, that if a line starts with a `-` then perhaps it belongs to a list. Once it recognises the blocks, it continues to the content. As it reads, it watches out for special characters. This helps it recognise inline elements (or inlines).
We call this approach "line based". We believe that Parsedown is the first Markdown parser to use it. Since the release of Parsedown, other developers have used the same approach to develop other Markdown parsers in PHP and in other languages.
**Is it compliant with CommonMark?**
It passes most of the CommonMark tests. Most of the tests that don't pass deal with cases that are quite uncommon. Still, as CommonMark matures, compliance should improve.
**Who uses it?**
[Laravel Framework](https://laravel.com/), [Bolt CMS](http://bolt.cm/), [Grav CMS](http://getgrav.org/), [Herbie CMS](http://www.getherbie.org/), [Kirby CMS](http://getkirby.com/), [October CMS](http://octobercms.com/), [Pico CMS](http://picocms.org), [Statamic CMS](http://www.statamic.com/), [phpDocumentor](http://www.phpdoc.org/), [RaspberryPi.org](http://www.raspberrypi.org/), [Symfony demo](https://github.com/symfony/symfony-demo) and [more](https://packagist.org/packages/erusev/parsedown/dependents).
**How can I help?**
Use it, star it, share it and if you feel generous, [donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=528P3NZQMP8N2).

33
vendor/erusev/parsedown/composer.json vendored Normal file
View File

@ -0,0 +1,33 @@
{
"name": "erusev/parsedown",
"description": "Parser for Markdown.",
"keywords": ["markdown", "parser"],
"homepage": "http://parsedown.org",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"require": {
"php": ">=5.3.0",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
},
"autoload": {
"psr-0": {"Parsedown": ""}
},
"autoload-dev": {
"psr-0": {
"TestParsedown": "test/",
"ParsedownTest": "test/",
"CommonMarkTest": "test/",
"CommonMarkTestWeak": "test/"
}
}
}

View File

@ -0,0 +1,5 @@
# Auto detect text files and perform LF normalization
* text=auto
tests/ export-ignore
.travis.yml export-ignore

3
vendor/mnapoli/front-yaml/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
vendor/*
composer.phar
composer.lock

18
vendor/mnapoli/front-yaml/LICENSE vendored Normal file
View File

@ -0,0 +1,18 @@
FrontYAML
Copyright (C) 2014 Matthieu Napoli
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

86
vendor/mnapoli/front-yaml/README.md vendored Normal file
View File

@ -0,0 +1,86 @@
# FrontYAML
An implementation of YAML Front matter for PHP. Can parse the YAML *and* the Markdown.
[![Build Status](https://travis-ci.org/mnapoli/FrontYAML.png?branch=master)](https://travis-ci.org/mnapoli/FrontYAML)
[![Total Downloads](https://poser.pugx.org/mnapoli/front-yaml/downloads.svg)](https://packagist.org/packages/mnapoli/front-yaml)
## Installation
Require the project with Composer:
```
composer require mnapoli/front-yaml
```
## Usage
```php
$parser = new Mni\FrontYAML\Parser();
$document = $parser->parse($str);
$yaml = $document->getYAML();
$html = $document->getContent();
```
If you don't want the Markdown to be parsed (maybe because it is not Markdown):
```php
$document = $parser->parse($str, false);
```
## Example
The following file:
```markdown
---
foo: bar
---
This is **strong**.
```
Will give:
```php
var_export($document->getYAML());
// array("foo" => "bar")
var_export($document->getContent());
// "<p>This is <strong>strong</strong></p>"
```
## YAML and Markdown parsers
```php
$parser = new Mni\FrontYAML\Parser($yamlParser, $markdownParser);
```
This library uses dependency injection and abstraction to allow you to provide your own YAML or Markdown parser.
```php
interface YAMLParser
{
public function parse($yaml);
}
```
FrontYAML uses by default [Symfony's YAML parser](http://symfony.com/doc/current/components/yaml/introduction.html).
```php
interface MarkdownParser
{
public function parse($markdown);
}
```
FrontYAML uses by default [Parsedown Markdown parser](http://parsedown.org/).
An adapter to [League CommonMark](https://github.com/thephpleague/commonmark) is also included (you need to require the `league/commonmark` though):
```php
use \Mni\FrontYAML\Bridge\CommonMark\CommonMarkParser;
$parser = new Mni\FrontYAML\Parser(null, new CommonMarkParser());
```

23
vendor/mnapoli/front-yaml/composer.json vendored Normal file
View File

@ -0,0 +1,23 @@
{
"name": "mnapoli/front-yaml",
"license": "MIT",
"autoload": {
"psr-4": {
"Mni\\FrontYAML\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Mni\\FrontYAML\\Test\\": "tests/"
}
},
"require": {
"php": ">=5.4.0",
"symfony/yaml": "~2.1|^3.0|^4.0",
"erusev/parsedown": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.5",
"league/commonmark": "~0.7"
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
phpunit -c phpunit.xml
-->
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Tests">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@ -0,0 +1,33 @@
<?php
/**
* FrontYAML
*
* @copyright Matthieu Napoli http://mnapoli.fr
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
*/
namespace Mni\FrontYAML\Bridge\CommonMark;
use League\CommonMark\CommonMarkConverter;
use Mni\FrontYAML\Markdown\MarkdownParser;
/**
* Bridge to the League CommonMark parser
*
* @author Matthieu Napoli <matthieu@mnapoli.fr>
*/
class CommonMarkParser implements MarkdownParser
{
public function __construct(CommonMarkConverter $commonMarkConverter = null)
{
$this->parser = $commonMarkConverter ?: new CommonMarkConverter();
}
/**
* {@inheritdoc}
*/
public function parse($markdown)
{
return $this->parser->convertToHtml($markdown);
}
}

View File

@ -0,0 +1,33 @@
<?php
/**
* FrontYAML
*
* @copyright Matthieu Napoli http://mnapoli.fr
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
*/
namespace Mni\FrontYAML\Bridge\Parsedown;
use Mni\FrontYAML\Markdown\MarkdownParser;
use Parsedown;
/**
* Bridge to the Parsedown Markdown parser
*
* @author Matthieu Napoli <matthieu@mnapoli.fr>
*/
class ParsedownParser implements MarkdownParser
{
public function __construct(Parsedown $parsedown = null)
{
$this->parser = $parsedown ?: new Parsedown();
}
/**
* {@inheritdoc}
*/
public function parse($markdown)
{
return $this->parser->parse($markdown);
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* FrontYAML
*
* @copyright Matthieu Napoli http://mnapoli.fr
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
*/
namespace Mni\FrontYAML\Bridge\Symfony;
use Mni\FrontYAML\YAML\YAMLParser;
use Symfony\Component\Yaml\Parser;
/**
* Bridge to the Symfony YAML parser
*
* @author Matthieu Napoli <matthieu@mnapoli.fr>
*/
class SymfonyYAMLParser implements YAMLParser
{
/**
* @var Parser
*/
private $parser;
public function __construct()
{
$this->parser = new Parser();
}
/**
* {@inheritdoc}
*/
public function parse($yaml)
{
return $this->parser->parse($yaml);
}
}

View File

@ -0,0 +1,53 @@
<?php
/**
* FrontYAML
*
* @copyright Matthieu Napoli http://mnapoli.fr
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
*/
namespace Mni\FrontYAML;
/**
* Document.
*
* @author Matthieu Napoli <matthieu@mnapoli.fr>
*/
class Document
{
/**
* @var mixed
*/
private $yaml;
/**
* @var string
*/
private $content;
/**
* @param mixed $yaml YAML content.
* @param string $content Content of the document.
*/
public function __construct($yaml, $content)
{
$this->yaml = $yaml;
$this->content = $content;
}
/**
* @return mixed YAML content.
*/
public function getYAML()
{
return $this->yaml;
}
/**
* @return string Content of the document.
*/
public function getContent()
{
return $this->content;
}
}

View File

@ -0,0 +1,26 @@
<?php
/**
* FrontYAML
*
* @copyright Matthieu Napoli http://mnapoli.fr
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
*/
namespace Mni\FrontYAML\Markdown;
/**
* Interface of a Markdown parser
*
* @author Matthieu Napoli <matthieu@mnapoli.fr>
*/
interface MarkdownParser
{
/**
* Parses a Markdown string to HTML.
*
* @param string $markdown Markdown document.
*
* @return string HTML document.
*/
public function parse($markdown);
}

View File

@ -0,0 +1,84 @@
<?php
/**
* FrontYAML
*
* @copyright Matthieu Napoli http://mnapoli.fr
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
*/
namespace Mni\FrontYAML;
use Mni\FrontYAML\Bridge\Parsedown\ParsedownParser;
use Mni\FrontYAML\Bridge\Symfony\SymfonyYAMLParser;
use Mni\FrontYAML\Markdown\MarkdownParser;
use Mni\FrontYAML\YAML\YAMLParser;
/**
* YAML Front matter parser
*
* @author Matthieu Napoli <matthieu@mnapoli.fr>
*/
class Parser
{
/**
* @var YAMLParser
*/
private $yamlParser;
/**
* @var MarkdownParser
*/
private $markdownParser;
/**
* @var array
*/
private $startSep;
/**
* @var array
*/
private $endSep;
public function __construct(
YAMLParser $yamlParser = null,
MarkdownParser $markdownParser = null,
$startSep = '---',
$endSep = '---'
) {
$this->yamlParser = $yamlParser ?: new SymfonyYAMLParser();
$this->markdownParser = $markdownParser ?: new ParsedownParser();
$this->startSep = array_filter((array) $startSep, 'is_string') ?: array('---');
$this->endSep = array_filter((array) $endSep, 'is_string') ?: array('---');
}
/**
* Parse a string containing the YAML front matter and the markdown.
*
* @param string $str
* @param bool $parseMarkdown Should the Markdown be turned into HTML?
*
* @return Document
*/
public function parse($str, $parseMarkdown = true)
{
$yaml = null;
$quote = function ($str) {
return preg_quote($str, "~");
};
$regex = '~^('
.implode('|', array_map($quote, $this->startSep)) # $matches[1] start separator
."){1}[\r\n|\n]*(.*?)[\r\n|\n]+(" # $matches[2] between separators
.implode('|', array_map($quote, $this->endSep)) # $matches[3] end separator
."){1}[\r\n|\n]*(.*)$~s"; # $matches[4] document content
if (preg_match($regex, $str, $matches) === 1) { // There is a Front matter
$yaml = trim($matches[2]) !== '' ? $this->yamlParser->parse(trim($matches[2])) : null;
$str = ltrim($matches[4]);
}
return new Document($yaml, $parseMarkdown ? $this->markdownParser->parse($str) : $str);
}
}

View File

@ -0,0 +1,26 @@
<?php
/**
* FrontYAML
*
* @copyright Matthieu Napoli http://mnapoli.fr
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
*/
namespace Mni\FrontYAML\YAML;
/**
* Interface of a YAML parser
*
* @author Matthieu Napoli <matthieu@mnapoli.fr>
*/
interface YAMLParser
{
/**
* Parses a YAML string.
*
* @param string $yaml
*
* @return mixed
*/
public function parse($yaml);
}

227
vendor/symfony/polyfill-ctype/Ctype.php vendored Normal file
View File

@ -0,0 +1,227 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Polyfill\Ctype;
/**
* Ctype implementation through regex.
*
* @internal
*
* @author Gert de Pagter <BackEndTea@gmail.com>
*/
final class Ctype
{
/**
* Returns TRUE if every character in text is either a letter or a digit, FALSE otherwise.
*
* @see https://php.net/ctype-alnum
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_alnum($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
}
/**
* Returns TRUE if every character in text is a letter, FALSE otherwise.
*
* @see https://php.net/ctype-alpha
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_alpha($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
}
/**
* Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.
*
* @see https://php.net/ctype-cntrl
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_cntrl($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
}
/**
* Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise.
*
* @see https://php.net/ctype-digit
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_digit($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
}
/**
* Returns TRUE if every character in text is printable and actually creates visible output (no white space), FALSE otherwise.
*
* @see https://php.net/ctype-graph
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_graph($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
}
/**
* Returns TRUE if every character in text is a lowercase letter.
*
* @see https://php.net/ctype-lower
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_lower($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
}
/**
* Returns TRUE if every character in text will actually create output (including blanks). Returns FALSE if text contains control characters or characters that do not have any output or control function at all.
*
* @see https://php.net/ctype-print
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_print($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
}
/**
* Returns TRUE if every character in text is printable, but neither letter, digit or blank, FALSE otherwise.
*
* @see https://php.net/ctype-punct
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_punct($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
}
/**
* Returns TRUE if every character in text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters.
*
* @see https://php.net/ctype-space
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_space($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
}
/**
* Returns TRUE if every character in text is an uppercase letter.
*
* @see https://php.net/ctype-upper
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_upper($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
}
/**
* Returns TRUE if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f] , FALSE otherwise.
*
* @see https://php.net/ctype-xdigit
*
* @param string|int $text
*
* @return bool
*/
public static function ctype_xdigit($text)
{
$text = self::convert_int_to_char_for_ctype($text);
return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
}
/**
* Converts integers to their char versions according to normal ctype behaviour, if needed.
*
* If an integer between -128 and 255 inclusive is provided,
* it is interpreted as the ASCII value of a single character
* (negative values have 256 added in order to allow characters in the Extended ASCII range).
* Any other integer is interpreted as a string containing the decimal digits of the integer.
*
* @param string|int $int
*
* @return mixed
*/
private static function convert_int_to_char_for_ctype($int)
{
if (!\is_int($int)) {
return $int;
}
if ($int < -128 || $int > 255) {
return (string) $int;
}
if ($int < 0) {
$int += 256;
}
return \chr($int);
}
}

19
vendor/symfony/polyfill-ctype/LICENSE vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2018-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

12
vendor/symfony/polyfill-ctype/README.md vendored Normal file
View File

@ -0,0 +1,12 @@
Symfony Polyfill / Ctype
========================
This component provides `ctype_*` functions to users who run php versions without the ctype extension.
More information can be found in the
[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md).
License
=======
This library is released under the [MIT license](LICENSE).

View File

@ -0,0 +1,26 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Symfony\Polyfill\Ctype as p;
if (!function_exists('ctype_alnum')) {
function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); }
function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); }
function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); }
function ctype_digit($text) { return p\Ctype::ctype_digit($text); }
function ctype_graph($text) { return p\Ctype::ctype_graph($text); }
function ctype_lower($text) { return p\Ctype::ctype_lower($text); }
function ctype_print($text) { return p\Ctype::ctype_print($text); }
function ctype_punct($text) { return p\Ctype::ctype_punct($text); }
function ctype_space($text) { return p\Ctype::ctype_space($text); }
function ctype_upper($text) { return p\Ctype::ctype_upper($text); }
function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); }
}

View File

@ -0,0 +1,34 @@
{
"name": "symfony/polyfill-ctype",
"type": "library",
"description": "Symfony polyfill for ctype functions",
"keywords": ["polyfill", "compatibility", "portable", "ctype"],
"homepage": "https://symfony.com",
"license": "MIT",
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"require": {
"php": ">=5.3.3"
},
"autoload": {
"psr-4": { "Symfony\\Polyfill\\Ctype\\": "" },
"files": [ "bootstrap.php" ]
},
"suggest": {
"ext-ctype": "For best performance"
},
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "1.14-dev"
}
}
}

3
vendor/symfony/yaml/.gitattributes vendored Normal file
View File

@ -0,0 +1,3 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitignore export-ignore

196
vendor/symfony/yaml/CHANGELOG.md vendored Normal file
View File

@ -0,0 +1,196 @@
CHANGELOG
=========
4.4.0
-----
* Added support for parsing the inline notation spanning multiple lines.
* Added support to dump `null` as `~` by using the `Yaml::DUMP_NULL_AS_TILDE` flag.
* deprecated accepting STDIN implicitly when using the `lint:yaml` command, use `lint:yaml -` (append a dash) instead to make it explicit.
4.3.0
-----
* Using a mapping inside a multi-line string is deprecated and will throw a `ParseException` in 5.0.
4.2.0
-----
* added support for multiple files or directories in `LintCommand`
4.0.0
-----
* The behavior of the non-specific tag `!` is changed and now forces
non-evaluating your values.
* complex mappings will throw a `ParseException`
* support for the comma as a group separator for floats has been dropped, use
the underscore instead
* support for the `!!php/object` tag has been dropped, use the `!php/object`
tag instead
* duplicate mapping keys throw a `ParseException`
* non-string mapping keys throw a `ParseException`, use the `Yaml::PARSE_KEYS_AS_STRINGS`
flag to cast them to strings
* `%` at the beginning of an unquoted string throw a `ParseException`
* mappings with a colon (`:`) that is not followed by a whitespace throw a
`ParseException`
* the `Dumper::setIndentation()` method has been removed
* being able to pass boolean options to the `Yaml::parse()`, `Yaml::dump()`,
`Parser::parse()`, and `Dumper::dump()` methods to configure the behavior of
the parser and dumper is no longer supported, pass bitmask flags instead
* the constructor arguments of the `Parser` class have been removed
* the `Inline` class is internal and no longer part of the BC promise
* removed support for the `!str` tag, use the `!!str` tag instead
* added support for tagged scalars.
```yml
Yaml::parse('!foo bar', Yaml::PARSE_CUSTOM_TAGS);
// returns TaggedValue('foo', 'bar');
```
3.4.0
-----
* added support for parsing YAML files using the `Yaml::parseFile()` or `Parser::parseFile()` method
* the `Dumper`, `Parser`, and `Yaml` classes are marked as final
* Deprecated the `!php/object:` tag which will be replaced by the
`!php/object` tag (without the colon) in 4.0.
* Deprecated the `!php/const:` tag which will be replaced by the
`!php/const` tag (without the colon) in 4.0.
* Support for the `!str` tag is deprecated, use the `!!str` tag instead.
* Deprecated using the non-specific tag `!` as its behavior will change in 4.0.
It will force non-evaluating your values in 4.0. Use plain integers or `!!float` instead.
3.3.0
-----
* Starting an unquoted string with a question mark followed by a space is
deprecated and will throw a `ParseException` in Symfony 4.0.
* Deprecated support for implicitly parsing non-string mapping keys as strings.
Mapping keys that are no strings will lead to a `ParseException` in Symfony
4.0. Use quotes to opt-in for keys to be parsed as strings.
Before:
```php
$yaml = <<<YAML
null: null key
true: boolean true
2.0: float key
YAML;
Yaml::parse($yaml);
```
After:
```php
$yaml = <<<YAML
"null": null key
"true": boolean true
"2.0": float key
YAML;
Yaml::parse($yaml);
```
* Omitted mapping values will be parsed as `null`.
* Omitting the key of a mapping is deprecated and will throw a `ParseException` in Symfony 4.0.
* Added support for dumping empty PHP arrays as YAML sequences:
```php
Yaml::dump([], 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
```
3.2.0
-----
* Mappings with a colon (`:`) that is not followed by a whitespace are deprecated
when the mapping key is not quoted and will lead to a `ParseException` in
Symfony 4.0 (e.g. `foo:bar` must be `foo: bar`).
* Added support for parsing PHP constants:
```php
Yaml::parse('!php/const:PHP_INT_MAX', Yaml::PARSE_CONSTANT);
```
* Support for silently ignoring duplicate mapping keys in YAML has been
deprecated and will lead to a `ParseException` in Symfony 4.0.
3.1.0
-----
* Added support to dump `stdClass` and `ArrayAccess` objects as YAML mappings
through the `Yaml::DUMP_OBJECT_AS_MAP` flag.
* Strings that are not UTF-8 encoded will be dumped as base64 encoded binary
data.
* Added support for dumping multi line strings as literal blocks.
* Added support for parsing base64 encoded binary data when they are tagged
with the `!!binary` tag.
* Added support for parsing timestamps as `\DateTime` objects:
```php
Yaml::parse('2001-12-15 21:59:43.10 -5', Yaml::PARSE_DATETIME);
```
* `\DateTime` and `\DateTimeImmutable` objects are dumped as YAML timestamps.
* Deprecated usage of `%` at the beginning of an unquoted string.
* Added support for customizing the YAML parser behavior through an optional bit field:
```php
Yaml::parse('{ "foo": "bar", "fiz": "cat" }', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE | Yaml::PARSE_OBJECT | Yaml::PARSE_OBJECT_FOR_MAP);
```
* Added support for customizing the dumped YAML string through an optional bit field:
```php
Yaml::dump(['foo' => new A(), 'bar' => 1], 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE | Yaml::DUMP_OBJECT);
```
3.0.0
-----
* Yaml::parse() now throws an exception when a blackslash is not escaped
in double-quoted strings
2.8.0
-----
* Deprecated usage of a colon in an unquoted mapping value
* Deprecated usage of @, \`, | and > at the beginning of an unquoted string
* When surrounding strings with double-quotes, you must now escape `\` characters. Not
escaping those characters (when surrounded by double-quotes) is deprecated.
Before:
```yml
class: "Foo\Var"
```
After:
```yml
class: "Foo\\Var"
```
2.1.0
-----
* Yaml::parse() does not evaluate loaded files as PHP files by default
anymore (call Yaml::enablePhpParsing() to get back the old behavior)

View File

@ -0,0 +1,255 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Yaml\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Yaml;
/**
* Validates YAML files syntax and outputs encountered errors.
*
* @author Grégoire Pineau <lyrixx@lyrixx.info>
* @author Robin Chalas <robin.chalas@gmail.com>
*/
class LintCommand extends Command
{
protected static $defaultName = 'lint:yaml';
private $parser;
private $format;
private $displayCorrectFiles;
private $directoryIteratorProvider;
private $isReadableProvider;
public function __construct(string $name = null, callable $directoryIteratorProvider = null, callable $isReadableProvider = null)
{
parent::__construct($name);
$this->directoryIteratorProvider = $directoryIteratorProvider;
$this->isReadableProvider = $isReadableProvider;
}
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setDescription('Lints a file and outputs encountered errors')
->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN')
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
->addOption('parse-tags', null, InputOption::VALUE_NONE, 'Parse custom tags')
->setHelp(<<<EOF
The <info>%command.name%</info> command lints a YAML file and outputs to STDOUT
the first encountered syntax error.
You can validates YAML contents passed from STDIN:
<info>cat filename | php %command.full_name% -</info>
You can also validate the syntax of a file:
<info>php %command.full_name% filename</info>
Or of a whole directory:
<info>php %command.full_name% dirname</info>
<info>php %command.full_name% dirname --format=json</info>
EOF
)
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$filenames = (array) $input->getArgument('filename');
$this->format = $input->getOption('format');
$this->displayCorrectFiles = $output->isVerbose();
$flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0;
if (['-'] === $filenames) {
return $this->display($io, [$this->validate(file_get_contents('php://stdin'), $flags)]);
}
// @deprecated to be removed in 5.0
if (!$filenames) {
if (0 === ftell(STDIN)) {
@trigger_error('Piping content from STDIN to the "lint:yaml" command without passing the dash symbol "-" as argument is deprecated since Symfony 4.4.', E_USER_DEPRECATED);
return $this->display($io, [$this->validate(file_get_contents('php://stdin'), $flags)]);
}
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
}
$filesInfo = [];
foreach ($filenames as $filename) {
if (!$this->isReadable($filename)) {
throw new RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
}
foreach ($this->getFiles($filename) as $file) {
$filesInfo[] = $this->validate(file_get_contents($file), $flags, $file);
}
}
return $this->display($io, $filesInfo);
}
private function validate(string $content, int $flags, string $file = null)
{
$prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) {
if (E_USER_DEPRECATED === $level) {
throw new ParseException($message, $this->getParser()->getRealCurrentLineNb() + 1);
}
return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false;
});
try {
$this->getParser()->parse($content, Yaml::PARSE_CONSTANT | $flags);
} catch (ParseException $e) {
return ['file' => $file, 'line' => $e->getParsedLine(), 'valid' => false, 'message' => $e->getMessage()];
} finally {
restore_error_handler();
}
return ['file' => $file, 'valid' => true];
}
private function display(SymfonyStyle $io, array $files): int
{
switch ($this->format) {
case 'txt':
return $this->displayTxt($io, $files);
case 'json':
return $this->displayJson($io, $files);
default:
throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $this->format));
}
}
private function displayTxt(SymfonyStyle $io, array $filesInfo): int
{
$countFiles = \count($filesInfo);
$erroredFiles = 0;
$suggestTagOption = false;
foreach ($filesInfo as $info) {
if ($info['valid'] && $this->displayCorrectFiles) {
$io->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
} elseif (!$info['valid']) {
++$erroredFiles;
$io->text('<error> ERROR </error>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
$io->text(sprintf('<error> >> %s</error>', $info['message']));
if (false !== strpos($info['message'], 'PARSE_CUSTOM_TAGS')) {
$suggestTagOption = true;
}
}
}
if (0 === $erroredFiles) {
$io->success(sprintf('All %d YAML files contain valid syntax.', $countFiles));
} else {
$io->warning(sprintf('%d YAML files have valid syntax and %d contain errors.%s', $countFiles - $erroredFiles, $erroredFiles, $suggestTagOption ? ' Use the --parse-tags option if you want parse custom tags.' : ''));
}
return min($erroredFiles, 1);
}
private function displayJson(SymfonyStyle $io, array $filesInfo): int
{
$errors = 0;
array_walk($filesInfo, function (&$v) use (&$errors) {
$v['file'] = (string) $v['file'];
if (!$v['valid']) {
++$errors;
}
if (isset($v['message']) && false !== strpos($v['message'], 'PARSE_CUSTOM_TAGS')) {
$v['message'] .= ' Use the --parse-tags option if you want parse custom tags.';
}
});
$io->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
return min($errors, 1);
}
private function getFiles(string $fileOrDirectory): iterable
{
if (is_file($fileOrDirectory)) {
yield new \SplFileInfo($fileOrDirectory);
return;
}
foreach ($this->getDirectoryIterator($fileOrDirectory) as $file) {
if (!\in_array($file->getExtension(), ['yml', 'yaml'])) {
continue;
}
yield $file;
}
}
private function getParser(): Parser
{
if (!$this->parser) {
$this->parser = new Parser();
}
return $this->parser;
}
private function getDirectoryIterator(string $directory): iterable
{
$default = function ($directory) {
return new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
\RecursiveIteratorIterator::LEAVES_ONLY
);
};
if (null !== $this->directoryIteratorProvider) {
return ($this->directoryIteratorProvider)($directory, $default);
}
return $default($directory);
}
private function isReadable(string $fileOrDirectory): bool
{
$default = function ($fileOrDirectory) {
return is_readable($fileOrDirectory);
};
if (null !== $this->isReadableProvider) {
return ($this->isReadableProvider)($fileOrDirectory, $default);
}
return $default($fileOrDirectory);
}
}

125
vendor/symfony/yaml/Dumper.php vendored Normal file
View File

@ -0,0 +1,125 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Yaml;
use Symfony\Component\Yaml\Tag\TaggedValue;
/**
* Dumper dumps PHP variables to YAML strings.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final
*/
class Dumper
{
/**
* The amount of spaces to use for indentation of nested nodes.
*
* @var int
*/
protected $indentation;
public function __construct(int $indentation = 4)
{
if ($indentation < 1) {
throw new \InvalidArgumentException('The indentation must be greater than zero.');
}
$this->indentation = $indentation;
}
/**
* Dumps a PHP value to YAML.
*
* @param mixed $input The PHP value
* @param int $inline The level where you switch to inline YAML
* @param int $indent The level of indentation (used internally)
* @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
*
* @return string The YAML representation of the PHP value
*/
public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0): string
{
$output = '';
$prefix = $indent ? str_repeat(' ', $indent) : '';
$dumpObjectAsInlineMap = true;
if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($input instanceof \ArrayObject || $input instanceof \stdClass)) {
$dumpObjectAsInlineMap = empty((array) $input);
}
if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || empty($input)) {
$output .= $prefix.Inline::dump($input, $flags);
} else {
$dumpAsMap = Inline::isHash($input);
foreach ($input as $key => $value) {
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r\n")) {
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
// http://www.yaml.org/spec/1.2/spec.html#id2793979
$blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : '';
$output .= sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator);
foreach (explode("\n", $value) as $row) {
$output .= sprintf("%s%s%s\n", $prefix, str_repeat(' ', $this->indentation), $row);
}
continue;
}
if ($value instanceof TaggedValue) {
$output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag());
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && false !== strpos($value->getValue(), "\n") && false === strpos($value->getValue(), "\r\n")) {
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
// http://www.yaml.org/spec/1.2/spec.html#id2793979
$blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string) $this->indentation : '';
$output .= sprintf(" |%s\n", $blockIndentationIndicator);
foreach (explode("\n", $value->getValue()) as $row) {
$output .= sprintf("%s%s%s\n", $prefix, str_repeat(' ', $this->indentation), $row);
}
continue;
}
if ($inline - 1 <= 0 || null === $value->getValue() || is_scalar($value->getValue())) {
$output .= ' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n";
} else {
$output .= "\n";
$output .= $this->dump($value->getValue(), $inline - 1, $dumpAsMap ? $indent + $this->indentation : $indent + 2, $flags);
}
continue;
}
$dumpObjectAsInlineMap = true;
if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) {
$dumpObjectAsInlineMap = empty((array) $value);
}
$willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || empty($value);
$output .= sprintf('%s%s%s%s',
$prefix,
$dumpAsMap ? Inline::dump($key, $flags).':' : '-',
$willBeInlined ? ' ' : "\n",
$this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $flags)
).($willBeInlined ? "\n" : '');
}
}
return $output;
}
}

101
vendor/symfony/yaml/Escaper.php vendored Normal file
View File

@ -0,0 +1,101 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Yaml;
/**
* Escaper encapsulates escaping rules for single and double-quoted
* YAML strings.
*
* @author Matthew Lewinski <matthew@lewinski.org>
*
* @internal
*/
class Escaper
{
// Characters that would cause a dumped string to require double quoting.
const REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9";
// Mapping arrays for escaping a double quoted string. The backslash is
// first to ensure proper escaping because str_replace operates iteratively
// on the input arrays. This ordering of the characters avoids the use of strtr,
// which performs more slowly.
private static $escapees = ['\\', '\\\\', '\\"', '"',
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
"\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
"\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
"\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",
];
private static $escaped = ['\\\\', '\\"', '\\\\', '\\"',
'\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a',
'\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f',
'\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17',
'\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f',
'\\N', '\\_', '\\L', '\\P',
];
/**
* Determines if a PHP value would require double quoting in YAML.
*
* @param string $value A PHP value
*
* @return bool True if the value would require double quotes
*/
public static function requiresDoubleQuoting(string $value): bool
{
return 0 < preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value);
}
/**
* Escapes and surrounds a PHP value with double quotes.
*
* @param string $value A PHP value
*
* @return string The quoted, escaped string
*/
public static function escapeWithDoubleQuotes(string $value): string
{
return sprintf('"%s"', str_replace(self::$escapees, self::$escaped, $value));
}
/**
* Determines if a PHP value would require single quoting in YAML.
*
* @param string $value A PHP value
*
* @return bool True if the value would require single quotes
*/
public static function requiresSingleQuoting(string $value): bool
{
// Determines if a PHP value is entirely composed of a value that would
// require single quoting in YAML.
if (\in_array(strtolower($value), ['null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'])) {
return true;
}
// Determines if the PHP value contains any single characters that would
// cause it to require single quoting in YAML.
return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
}
/**
* Escapes and surrounds a PHP value with single quotes.
*
* @param string $value A PHP value
*
* @return string The quoted, escaped string
*/
public static function escapeWithSingleQuotes(string $value): string
{
return sprintf("'%s'", str_replace('\'', '\'\'', $value));
}
}

View File

@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Yaml\Exception;
/**
* Exception class thrown when an error occurs during dumping.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class DumpException extends RuntimeException
{
}

View File

@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Yaml\Exception;
/**
* Exception interface for all exceptions thrown by the component.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface ExceptionInterface extends \Throwable
{
}

View File

@ -0,0 +1,139 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Yaml\Exception;
/**
* Exception class thrown when an error occurs during parsing.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ParseException extends RuntimeException
{
private $parsedFile;
private $parsedLine;
private $snippet;
private $rawMessage;
/**
* @param string $message The error message
* @param int $parsedLine The line where the error occurred
* @param string|null $snippet The snippet of code near the problem
* @param string|null $parsedFile The file name where the error occurred
* @param \Exception|null $previous The previous exception
*/
public function __construct(string $message, int $parsedLine = -1, string $snippet = null, string $parsedFile = null, \Throwable $previous = null)
{
$this->parsedFile = $parsedFile;
$this->parsedLine = $parsedLine;
$this->snippet = $snippet;
$this->rawMessage = $message;
$this->updateRepr();
parent::__construct($this->message, 0, $previous);
}
/**
* Gets the snippet of code near the error.
*
* @return string The snippet of code
*/
public function getSnippet()
{
return $this->snippet;
}
/**
* Sets the snippet of code near the error.
*
* @param string $snippet The code snippet
*/
public function setSnippet($snippet)
{
$this->snippet = $snippet;
$this->updateRepr();
}
/**
* Gets the filename where the error occurred.
*
* This method returns null if a string is parsed.
*
* @return string The filename
*/
public function getParsedFile()
{
return $this->parsedFile;
}
/**
* Sets the filename where the error occurred.
*
* @param string $parsedFile The filename
*/
public function setParsedFile($parsedFile)
{
$this->parsedFile = $parsedFile;
$this->updateRepr();
}
/**
* Gets the line where the error occurred.
*
* @return int The file line
*/
public function getParsedLine()
{
return $this->parsedLine;
}
/**
* Sets the line where the error occurred.
*
* @param int $parsedLine The file line
*/
public function setParsedLine($parsedLine)
{
$this->parsedLine = $parsedLine;
$this->updateRepr();
}
private function updateRepr()
{
$this->message = $this->rawMessage;
$dot = false;
if ('.' === substr($this->message, -1)) {
$this->message = substr($this->message, 0, -1);
$dot = true;
}
if (null !== $this->parsedFile) {
$this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
}
if ($this->parsedLine >= 0) {
$this->message .= sprintf(' at line %d', $this->parsedLine);
}
if ($this->snippet) {
$this->message .= sprintf(' (near "%s")', $this->snippet);
}
if ($dot) {
$this->message .= '.';
}
}
}

View File

@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Yaml\Exception;
/**
* Exception class thrown when an error occurs during parsing.
*
* @author Romain Neutron <imprec@gmail.com>
*/
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}

762
vendor/symfony/yaml/Inline.php vendored Normal file
View File

@ -0,0 +1,762 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Yaml;
use Symfony\Component\Yaml\Exception\DumpException;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Tag\TaggedValue;
/**
* Inline implements a YAML parser/dumper for the YAML inline syntax.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @internal
*/
class Inline
{
const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*+(?:\\\\.[^"\\\\]*+)*+)"|\'([^\']*+(?:\'\'[^\']*+)*+)\')';
public static $parsedLineNumber = -1;
public static $parsedFilename;
private static $exceptionOnInvalidType = false;
private static $objectSupport = false;
private static $objectForMap = false;
private static $constantSupport = false;
public static function initialize(int $flags, int $parsedLineNumber = null, string $parsedFilename = null)
{
self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags);
self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags);
self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags);
self::$constantSupport = (bool) (Yaml::PARSE_CONSTANT & $flags);
self::$parsedFilename = $parsedFilename;
if (null !== $parsedLineNumber) {
self::$parsedLineNumber = $parsedLineNumber;
}
}
/**
* Converts a YAML string to a PHP value.
*
* @param string $value A YAML string
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
* @param array $references Mapping of variable names to values
*
* @return mixed A PHP value
*
* @throws ParseException
*/
public static function parse(string $value = null, int $flags = 0, array $references = [])
{
self::initialize($flags);
$value = trim($value);
if ('' === $value) {
return '';
}
if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
}
try {
$i = 0;
$tag = self::parseTag($value, $i, $flags);
switch ($value[$i]) {
case '[':
$result = self::parseSequence($value, $flags, $i, $references);
++$i;
break;
case '{':
$result = self::parseMapping($value, $flags, $i, $references);
++$i;
break;
default:
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
}
// some comments are allowed at the end
if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}
if (null !== $tag && '' !== $tag) {
return new TaggedValue($tag, $result);
}
return $result;
} finally {
if (isset($mbEncoding)) {
mb_internal_encoding($mbEncoding);
}
}
}
/**
* Dumps a given PHP variable to a YAML string.
*
* @param mixed $value The PHP variable to convert
* @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
*
* @return string The YAML string representing the PHP value
*
* @throws DumpException When trying to dump PHP resource
*/
public static function dump($value, int $flags = 0): string
{
switch (true) {
case \is_resource($value):
if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) {
throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
}
return self::dumpNull($flags);
case $value instanceof \DateTimeInterface:
return $value->format('c');
case \is_object($value):
if ($value instanceof TaggedValue) {
return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags);
}
if (Yaml::DUMP_OBJECT & $flags) {
return '!php/object '.self::dump(serialize($value));
}
if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) {
$output = [];
foreach ($value as $key => $val) {
$output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
}
return sprintf('{ %s }', implode(', ', $output));
}
if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) {
throw new DumpException('Object support when dumping a YAML file has been disabled.');
}
return self::dumpNull($flags);
case \is_array($value):
return self::dumpArray($value, $flags);
case null === $value:
return self::dumpNull($flags);
case true === $value:
return 'true';
case false === $value:
return 'false';
case ctype_digit($value):
return \is_string($value) ? "'$value'" : (int) $value;
case is_numeric($value):
$locale = setlocale(LC_NUMERIC, 0);
if (false !== $locale) {
setlocale(LC_NUMERIC, 'C');
}
if (\is_float($value)) {
$repr = (string) $value;
if (is_infinite($value)) {
$repr = str_ireplace('INF', '.Inf', $repr);
} elseif (floor($value) == $value && $repr == $value) {
// Preserve float data type since storing a whole number will result in integer value.
$repr = '!!float '.$repr;
}
} else {
$repr = \is_string($value) ? "'$value'" : (string) $value;
}
if (false !== $locale) {
setlocale(LC_NUMERIC, $locale);
}
return $repr;
case '' == $value:
return "''";
case self::isBinaryString($value):
return '!!binary '.base64_encode($value);
case Escaper::requiresDoubleQuoting($value):
return Escaper::escapeWithDoubleQuotes($value);
case Escaper::requiresSingleQuoting($value):
case Parser::preg_match('{^[0-9]+[_0-9]*$}', $value):
case Parser::preg_match(self::getHexRegex(), $value):
case Parser::preg_match(self::getTimestampRegex(), $value):
return Escaper::escapeWithSingleQuotes($value);
default:
return $value;
}
}
/**
* Check if given array is hash or just normal indexed array.
*
* @param array|\ArrayObject|\stdClass $value The PHP array or array-like object to check
*
* @return bool true if value is hash array, false otherwise
*/
public static function isHash($value): bool
{
if ($value instanceof \stdClass || $value instanceof \ArrayObject) {
return true;
}
$expectedKey = 0;
foreach ($value as $key => $val) {
if ($key !== $expectedKey++) {
return true;
}
}
return false;
}
/**
* Dumps a PHP array to a YAML string.
*
* @param array $value The PHP array to dump
* @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
*
* @return string The YAML string representing the PHP array
*/
private static function dumpArray(array $value, int $flags): string
{
// array
if (($value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $flags) && !self::isHash($value)) {
$output = [];
foreach ($value as $val) {
$output[] = self::dump($val, $flags);
}
return sprintf('[%s]', implode(', ', $output));
}
// hash
$output = [];
foreach ($value as $key => $val) {
$output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
}
return sprintf('{ %s }', implode(', ', $output));
}
private static function dumpNull(int $flags): string
{
if (Yaml::DUMP_NULL_AS_TILDE & $flags) {
return '~';
}
return 'null';
}
/**
* Parses a YAML scalar.
*
* @return mixed
*
* @throws ParseException When malformed inline YAML string is parsed
*/
public static function parseScalar(string $scalar, int $flags = 0, array $delimiters = null, int &$i = 0, bool $evaluate = true, array $references = [])
{
if (\in_array($scalar[$i], ['"', "'"])) {
// quoted scalar
$output = self::parseQuotedScalar($scalar, $i);
if (null !== $delimiters) {
$tmp = ltrim(substr($scalar, $i), " \n");
if ('' === $tmp) {
throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode('', $delimiters)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
if (!\in_array($tmp[0], $delimiters)) {
throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
}
} else {
// "normal" string
if (!$delimiters) {
$output = substr($scalar, $i);
$i += \strlen($output);
// remove comments
if (Parser::preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
$output = substr($output, 0, $match[0][1]);
}
} elseif (Parser::preg_match('/^(.*?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
$output = $match[1];
$i += \strlen($output);
$output = trim($output);
} else {
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename);
}
// a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >)
if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0] || '%' === $output[0])) {
throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0]), self::$parsedLineNumber + 1, $output, self::$parsedFilename);
}
if ($evaluate) {
$output = self::evaluateScalar($output, $flags, $references);
}
}
return $output;
}
/**
* Parses a YAML quoted scalar.
*
* @throws ParseException When malformed inline YAML string is parsed
*/
private static function parseQuotedScalar(string $scalar, int &$i): string
{
if (!Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
throw new ParseException(sprintf('Malformed inline YAML string: %s.', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
$output = substr($match[0], 1, \strlen($match[0]) - 2);
$unescaper = new Unescaper();
if ('"' == $scalar[$i]) {
$output = $unescaper->unescapeDoubleQuotedString($output);
} else {
$output = $unescaper->unescapeSingleQuotedString($output);
}
$i += \strlen($match[0]);
return $output;
}
/**
* Parses a YAML sequence.
*
* @throws ParseException When malformed inline YAML string is parsed
*/
private static function parseSequence(string $sequence, int $flags, int &$i = 0, array $references = []): array
{
$output = [];
$len = \strlen($sequence);
++$i;
// [foo, bar, ...]
while ($i < $len) {
if (']' === $sequence[$i]) {
return $output;
}
if (',' === $sequence[$i] || ' ' === $sequence[$i]) {
++$i;
continue;
}
$tag = self::parseTag($sequence, $i, $flags);
switch ($sequence[$i]) {
case '[':
// nested sequence
$value = self::parseSequence($sequence, $flags, $i, $references);
break;
case '{':
// nested mapping
$value = self::parseMapping($sequence, $flags, $i, $references);
break;
default:
$isQuoted = \in_array($sequence[$i], ['"', "'"]);
$value = self::parseScalar($sequence, $flags, [',', ']'], $i, null === $tag, $references);
// the value can be an array if a reference has been resolved to an array var
if (\is_string($value) && !$isQuoted && false !== strpos($value, ': ')) {
// embedded mapping?
try {
$pos = 0;
$value = self::parseMapping('{'.$value.'}', $flags, $pos, $references);
} catch (\InvalidArgumentException $e) {
// no, it's not
}
}
--$i;
}
if (null !== $tag && '' !== $tag) {
$value = new TaggedValue($tag, $value);
}
$output[] = $value;
++$i;
}
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename);
}
/**
* Parses a YAML mapping.
*
* @return array|\stdClass
*
* @throws ParseException When malformed inline YAML string is parsed
*/
private static function parseMapping(string $mapping, int $flags, int &$i = 0, array $references = [])
{
$output = [];
$len = \strlen($mapping);
++$i;
$allowOverwrite = false;
// {foo: bar, bar:foo, ...}
while ($i < $len) {
switch ($mapping[$i]) {
case ' ':
case ',':
case "\n":
++$i;
continue 2;
case '}':
if (self::$objectForMap) {
return (object) $output;
}
return $output;
}
// key
$offsetBeforeKeyParsing = $i;
$isKeyQuoted = \in_array($mapping[$i], ['"', "'"], true);
$key = self::parseScalar($mapping, $flags, [':', ' '], $i, false, []);
if ($offsetBeforeKeyParsing === $i) {
throw new ParseException('Missing mapping key.', self::$parsedLineNumber + 1, $mapping);
}
if ('!php/const' === $key) {
$key .= ' '.self::parseScalar($mapping, $flags, [':'], $i, false, []);
$key = self::evaluateScalar($key, $flags);
}
if (false === $i = strpos($mapping, ':', $i)) {
break;
}
if (!$isKeyQuoted) {
$evaluatedKey = self::evaluateScalar($key, $flags, $references);
if ('' !== $key && $evaluatedKey !== $key && !\is_string($evaluatedKey) && !\is_int($evaluatedKey)) {
throw new ParseException('Implicit casting of incompatible mapping keys to strings is not supported. Quote your evaluable mapping keys instead.', self::$parsedLineNumber + 1, $mapping);
}
}
if (!$isKeyQuoted && (!isset($mapping[$i + 1]) || !\in_array($mapping[$i + 1], [' ', ',', '[', ']', '{', '}', "\n"], true))) {
throw new ParseException('Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}").', self::$parsedLineNumber + 1, $mapping);
}
if ('<<' === $key) {
$allowOverwrite = true;
}
while ($i < $len) {
if (':' === $mapping[$i] || ' ' === $mapping[$i] || "\n" === $mapping[$i]) {
++$i;
continue;
}
$tag = self::parseTag($mapping, $i, $flags);
switch ($mapping[$i]) {
case '[':
// nested sequence
$value = self::parseSequence($mapping, $flags, $i, $references);
// Spec: Keys MUST be unique; first one wins.
// Parser cannot abort this mapping earlier, since lines
// are processed sequentially.
// But overwriting is allowed when a merge node is used in current block.
if ('<<' === $key) {
foreach ($value as $parsedValue) {
$output += $parsedValue;
}
} elseif ($allowOverwrite || !isset($output[$key])) {
if (null !== $tag) {
$output[$key] = new TaggedValue($tag, $value);
} else {
$output[$key] = $value;
}
} elseif (isset($output[$key])) {
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
}
break;
case '{':
// nested mapping
$value = self::parseMapping($mapping, $flags, $i, $references);
// Spec: Keys MUST be unique; first one wins.
// Parser cannot abort this mapping earlier, since lines
// are processed sequentially.
// But overwriting is allowed when a merge node is used in current block.
if ('<<' === $key) {
$output += $value;
} elseif ($allowOverwrite || !isset($output[$key])) {
if (null !== $tag) {
$output[$key] = new TaggedValue($tag, $value);
} else {
$output[$key] = $value;
}
} elseif (isset($output[$key])) {
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
}
break;
default:
$value = self::parseScalar($mapping, $flags, [',', '}', "\n"], $i, null === $tag, $references);
// Spec: Keys MUST be unique; first one wins.
// Parser cannot abort this mapping earlier, since lines
// are processed sequentially.
// But overwriting is allowed when a merge node is used in current block.
if ('<<' === $key) {
$output += $value;
} elseif ($allowOverwrite || !isset($output[$key])) {
if (null !== $tag) {
$output[$key] = new TaggedValue($tag, $value);
} else {
$output[$key] = $value;
}
} elseif (isset($output[$key])) {
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
}
--$i;
}
++$i;
continue 2;
}
}
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $mapping), self::$parsedLineNumber + 1, null, self::$parsedFilename);
}
/**
* Evaluates scalars and replaces magic values.
*
* @return mixed The evaluated YAML string
*
* @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved
*/
private static function evaluateScalar(string $scalar, int $flags, array $references = [])
{
$scalar = trim($scalar);
$scalarLower = strtolower($scalar);
if (0 === strpos($scalar, '*')) {
if (false !== $pos = strpos($scalar, '#')) {
$value = substr($scalar, 1, $pos - 2);
} else {
$value = substr($scalar, 1);
}
// an unquoted *
if (false === $value || '' === $value) {
throw new ParseException('A reference must contain at least one character.', self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}
if (!\array_key_exists($value, $references)) {
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}
return $references[$value];
}
switch (true) {
case 'null' === $scalarLower:
case '' === $scalar:
case '~' === $scalar:
return null;
case 'true' === $scalarLower:
return true;
case 'false' === $scalarLower:
return false;
case '!' === $scalar[0]:
switch (true) {
case 0 === strpos($scalar, '!!str '):
return (string) substr($scalar, 6);
case 0 === strpos($scalar, '! '):
return substr($scalar, 2);
case 0 === strpos($scalar, '!php/object'):
if (self::$objectSupport) {
return unserialize(self::parseScalar(substr($scalar, 12)));
}
if (self::$exceptionOnInvalidType) {
throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
return null;
case 0 === strpos($scalar, '!php/const'):
if (self::$constantSupport) {
$i = 0;
if (\defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) {
return \constant($const);
}
throw new ParseException(sprintf('The constant "%s" is not defined.', $const), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
if (self::$exceptionOnInvalidType) {
throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
return null;
case 0 === strpos($scalar, '!!float '):
return (float) substr($scalar, 8);
case 0 === strpos($scalar, '!!binary '):
return self::evaluateBinaryScalar(substr($scalar, 9));
default:
throw new ParseException(sprintf('The string "%s" could not be parsed as it uses an unsupported built-in tag.', $scalar), self::$parsedLineNumber, $scalar, self::$parsedFilename);
}
// Optimize for returning strings.
// no break
case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || is_numeric($scalar[0]):
if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) {
$scalar = str_replace('_', '', (string) $scalar);
}
switch (true) {
case ctype_digit($scalar):
$raw = $scalar;
$cast = (int) $scalar;
return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
$raw = $scalar;
$cast = (int) $scalar;
return '0' == $scalar[1] ? -octdec(substr($scalar, 1)) : (($raw === (string) $cast) ? $cast : $raw);
case is_numeric($scalar):
case Parser::preg_match(self::getHexRegex(), $scalar):
$scalar = str_replace('_', '', $scalar);
return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar;
case '.inf' === $scalarLower:
case '.nan' === $scalarLower:
return -log(0);
case '-.inf' === $scalarLower:
return log(0);
case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar):
return (float) str_replace('_', '', $scalar);
case Parser::preg_match(self::getTimestampRegex(), $scalar):
if (Yaml::PARSE_DATETIME & $flags) {
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
return new \DateTime($scalar, new \DateTimeZone('UTC'));
}
$timeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$time = strtotime($scalar);
date_default_timezone_set($timeZone);
return $time;
}
}
return (string) $scalar;
}
private static function parseTag(string $value, int &$i, int $flags): ?string
{
if ('!' !== $value[$i]) {
return null;
}
$tagLength = strcspn($value, " \t\n[]{},", $i + 1);
$tag = substr($value, $i + 1, $tagLength);
$nextOffset = $i + $tagLength + 1;
$nextOffset += strspn($value, ' ', $nextOffset);
if ('' === $tag && (!isset($value[$nextOffset]) || \in_array($value[$nextOffset], [']', '}', ','], true))) {
throw new ParseException(sprintf('Using the unquoted scalar value "!" is not supported. You must quote it.', $value), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}
// Is followed by a scalar and is a built-in tag
if ('' !== $tag && (!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], ['[', '{'], true)) && ('!' === $tag[0] || 'str' === $tag || 'php/const' === $tag || 'php/object' === $tag)) {
// Manage in {@link self::evaluateScalar()}
return null;
}
$i = $nextOffset;
// Built-in tags
if ('' !== $tag && '!' === $tag[0]) {
throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}
if ('' !== $tag && !isset($value[$i])) {
throw new ParseException(sprintf('Missing value for tag "%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}
if ('' === $tag || Yaml::PARSE_CUSTOM_TAGS & $flags) {
return $tag;
}
throw new ParseException(sprintf('Tags support is not enabled. Enable the "Yaml::PARSE_CUSTOM_TAGS" flag to use "!%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}
public static function evaluateBinaryScalar(string $scalar): string
{
$parsedBinaryData = self::parseScalar(preg_replace('/\s/', '', $scalar));
if (0 !== (\strlen($parsedBinaryData) % 4)) {
throw new ParseException(sprintf('The normalized base64 encoded data (data without whitespace characters) length must be a multiple of four (%d bytes given).', \strlen($parsedBinaryData)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
if (!Parser::preg_match('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) {
throw new ParseException(sprintf('The base64 encoded data (%s) contains invalid characters.', $parsedBinaryData), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
return base64_decode($parsedBinaryData, true);
}
private static function isBinaryString(string $value)
{
return !preg_match('//u', $value) || preg_match('/[^\x00\x07-\x0d\x1B\x20-\xff]/', $value);
}
/**
* Gets a regex that matches a YAML date.
*
* @return string The regular expression
*
* @see http://www.yaml.org/spec/1.2/spec.html#id2761573
*/
private static function getTimestampRegex(): string
{
return <<<EOF
~^
(?P<year>[0-9][0-9][0-9][0-9])
-(?P<month>[0-9][0-9]?)
-(?P<day>[0-9][0-9]?)
(?:(?:[Tt]|[ \t]+)
(?P<hour>[0-9][0-9]?)
:(?P<minute>[0-9][0-9])
:(?P<second>[0-9][0-9])
(?:\.(?P<fraction>[0-9]*))?
(?:[ \t]*(?P<tz>Z|(?P<tz_sign>[-+])(?P<tz_hour>[0-9][0-9]?)
(?::(?P<tz_minute>[0-9][0-9]))?))?)?
$~x
EOF;
}
/**
* Gets a regex that matches a YAML number in hexadecimal notation.
*/
private static function getHexRegex(): string
{
return '~^0x[0-9a-f_]++$~i';
}
}

19
vendor/symfony/yaml/LICENSE vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2004-2020 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

1245
vendor/symfony/yaml/Parser.php vendored Normal file

File diff suppressed because it is too large Load Diff

13
vendor/symfony/yaml/README.md vendored Normal file
View File

@ -0,0 +1,13 @@
Yaml Component
==============
The Yaml component loads and dumps YAML files.
Resources
---------
* [Documentation](https://symfony.com/doc/current/components/yaml.html)
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
* [Report issues](https://github.com/symfony/symfony/issues) and
[send Pull Requests](https://github.com/symfony/symfony/pulls)
in the [main Symfony repository](https://github.com/symfony/symfony)

38
vendor/symfony/yaml/Tag/TaggedValue.php vendored Normal file
View File

@ -0,0 +1,38 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Yaml\Tag;
/**
* @author Nicolas Grekas <p@tchwork.com>
* @author Guilhem N. <egetick@gmail.com>
*/
final class TaggedValue
{
private $tag;
private $value;
public function __construct(string $tag, $value)
{
$this->tag = $tag;
$this->value = $value;
}
public function getTag(): string
{
return $this->tag;
}
public function getValue()
{
return $this->value;
}
}

138
vendor/symfony/yaml/Unescaper.php vendored Normal file
View File

@ -0,0 +1,138 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Yaml;
use Symfony\Component\Yaml\Exception\ParseException;
/**
* Unescaper encapsulates unescaping rules for single and double-quoted
* YAML strings.
*
* @author Matthew Lewinski <matthew@lewinski.org>
*
* @internal
*/
class Unescaper
{
/**
* Regex fragment that matches an escaped character in a double quoted string.
*/
const REGEX_ESCAPED_CHARACTER = '\\\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)';
/**
* Unescapes a single quoted string.
*
* @param string $value A single quoted string
*
* @return string The unescaped string
*/
public function unescapeSingleQuotedString(string $value): string
{
return str_replace('\'\'', '\'', $value);
}
/**
* Unescapes a double quoted string.
*
* @param string $value A double quoted string
*
* @return string The unescaped string
*/
public function unescapeDoubleQuotedString(string $value): string
{
$callback = function ($match) {
return $this->unescapeCharacter($match[0]);
};
// evaluate the string
return preg_replace_callback('/'.self::REGEX_ESCAPED_CHARACTER.'/u', $callback, $value);
}
/**
* Unescapes a character that was found in a double-quoted string.
*
* @param string $value An escaped character
*
* @return string The unescaped character
*/
private function unescapeCharacter(string $value): string
{
switch ($value[1]) {
case '0':
return "\x0";
case 'a':
return "\x7";
case 'b':
return "\x8";
case 't':
return "\t";
case "\t":
return "\t";
case 'n':
return "\n";
case 'v':
return "\xB";
case 'f':
return "\xC";
case 'r':
return "\r";
case 'e':
return "\x1B";
case ' ':
return ' ';
case '"':
return '"';
case '/':
return '/';
case '\\':
return '\\';
case 'N':
// U+0085 NEXT LINE
return "\xC2\x85";
case '_':
// U+00A0 NO-BREAK SPACE
return "\xC2\xA0";
case 'L':
// U+2028 LINE SEPARATOR
return "\xE2\x80\xA8";
case 'P':
// U+2029 PARAGRAPH SEPARATOR
return "\xE2\x80\xA9";
case 'x':
return self::utf8chr(hexdec(substr($value, 2, 2)));
case 'u':
return self::utf8chr(hexdec(substr($value, 2, 4)));
case 'U':
return self::utf8chr(hexdec(substr($value, 2, 8)));
default:
throw new ParseException(sprintf('Found unknown escape character "%s".', $value));
}
}
/**
* Get the UTF-8 character for the given code point.
*/
private static function utf8chr(int $c): string
{
if (0x80 > $c %= 0x200000) {
return \chr($c);
}
if (0x800 > $c) {
return \chr(0xC0 | $c >> 6).\chr(0x80 | $c & 0x3F);
}
if (0x10000 > $c) {
return \chr(0xE0 | $c >> 12).\chr(0x80 | $c >> 6 & 0x3F).\chr(0x80 | $c & 0x3F);
}
return \chr(0xF0 | $c >> 18).\chr(0x80 | $c >> 12 & 0x3F).\chr(0x80 | $c >> 6 & 0x3F).\chr(0x80 | $c & 0x3F);
}
}

102
vendor/symfony/yaml/Yaml.php vendored Normal file
View File

@ -0,0 +1,102 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Yaml;
use Symfony\Component\Yaml\Exception\ParseException;
/**
* Yaml offers convenience methods to load and dump YAML.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final
*/
class Yaml
{
const DUMP_OBJECT = 1;
const PARSE_EXCEPTION_ON_INVALID_TYPE = 2;
const PARSE_OBJECT = 4;
const PARSE_OBJECT_FOR_MAP = 8;
const DUMP_EXCEPTION_ON_INVALID_TYPE = 16;
const PARSE_DATETIME = 32;
const DUMP_OBJECT_AS_MAP = 64;
const DUMP_MULTI_LINE_LITERAL_BLOCK = 128;
const PARSE_CONSTANT = 256;
const PARSE_CUSTOM_TAGS = 512;
const DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024;
const DUMP_NULL_AS_TILDE = 2048;
/**
* Parses a YAML file into a PHP value.
*
* Usage:
*
* $array = Yaml::parseFile('config.yml');
* print_r($array);
*
* @param string $filename The path to the YAML file to be parsed
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
*
* @return mixed The YAML converted to a PHP value
*
* @throws ParseException If the file could not be read or the YAML is not valid
*/
public static function parseFile(string $filename, int $flags = 0)
{
$yaml = new Parser();
return $yaml->parseFile($filename, $flags);
}
/**
* Parses YAML into a PHP value.
*
* Usage:
* <code>
* $array = Yaml::parse(file_get_contents('config.yml'));
* print_r($array);
* </code>
*
* @param string $input A string containing YAML
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
*
* @return mixed The YAML converted to a PHP value
*
* @throws ParseException If the YAML is not valid
*/
public static function parse(string $input, int $flags = 0)
{
$yaml = new Parser();
return $yaml->parse($input, $flags);
}
/**
* Dumps a PHP value to a YAML string.
*
* The dump method, when supplied with an array, will do its best
* to convert the array into friendly YAML.
*
* @param mixed $input The PHP value
* @param int $inline The level where you switch to inline YAML
* @param int $indent The amount of spaces to use for indentation of nested nodes
* @param int $flags A bit field of DUMP_* constants to customize the dumped YAML string
*
* @return string A YAML string representing the original PHP value
*/
public static function dump($input, int $inline = 2, int $indent = 4, int $flags = 0): string
{
$yaml = new Dumper($indent);
return $yaml->dump($input, $inline, 0, $flags);
}
}

43
vendor/symfony/yaml/composer.json vendored Normal file
View File

@ -0,0 +1,43 @@
{
"name": "symfony/yaml",
"type": "library",
"description": "Symfony Yaml Component",
"keywords": [],
"homepage": "https://symfony.com",
"license": "MIT",
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"require": {
"php": "^7.1.3",
"symfony/polyfill-ctype": "~1.8"
},
"require-dev": {
"symfony/console": "^3.4|^4.0|^5.0"
},
"conflict": {
"symfony/console": "<3.4"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Yaml\\": "" },
"exclude-from-classmap": [
"/Tests/"
]
},
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
}
}
}

40
vendor/tildeverse/wiki/README.md vendored Normal file
View File

@ -0,0 +1,40 @@
# tildewiki
this is a small collection of parsedown extensions used across several tildeverse
sites to power the wiki.
## basic usage
1. add tildewiki as a vcs repository in composer.json
```json
"repositories": [
{
"type": "vcs",
"url": "https://tildegit.org/ben/tildewiki"
}
]
```
1. require tildeverse/wiki in composer.json
```json
"require": {
"tildeverse/wiki": "dev-master"
}
```
1. get an instance
```php
$parser = Tildeverse\Wiki\Parser::factory();
```
1. parse stuff
```php
$parsed = $parser->parse(file_get_contents("my.md"));
echo $parsed->getContent();
```
1. get yaml frontmatter values
```php
echo $parsed->getYAML()["my_yaml_key"];
```

20
vendor/tildeverse/wiki/composer.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
"name": "tildeverse/wiki",
"version": "0.0.1",
"description": "parsedown extensions for tilde wikis",
"type": "library",
"require": {
"erusev/parsedown-extra": "^0.7.1",
"mnapoli/front-yaml": "^1.6"
},
"autoload": {
"psr-4": {"Tildeverse\\Wiki\\": "src/"}
},
"license": "GPLv3",
"authors": [
{
"name": "Ben Harris",
"email": "ben@tilde.team"
}
]
}

260
vendor/tildeverse/wiki/composer.lock generated vendored Normal file
View File

@ -0,0 +1,260 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "81370fc8c2bc5b8d445fa858d3ec9107",
"packages": [
{
"name": "erusev/parsedown",
"version": "1.7.3",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown.git",
"reference": "6d893938171a817f4e9bc9e86f2da1e370b7bcd7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/6d893938171a817f4e9bc9e86f2da1e370b7bcd7",
"reference": "6d893938171a817f4e9bc9e86f2da1e370b7bcd7",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
},
"type": "library",
"autoload": {
"psr-0": {
"Parsedown": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "Parser for Markdown.",
"homepage": "http://parsedown.org",
"keywords": [
"markdown",
"parser"
],
"time": "2019-03-17T18:48:37+00:00"
},
{
"name": "erusev/parsedown-extra",
"version": "0.7.1",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown-extra.git",
"reference": "0db5cce7354e4b76f155d092ab5eb3981c21258c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown-extra/zipball/0db5cce7354e4b76f155d092ab5eb3981c21258c",
"reference": "0db5cce7354e4b76f155d092ab5eb3981c21258c",
"shasum": ""
},
"require": {
"erusev/parsedown": "~1.4"
},
"type": "library",
"autoload": {
"psr-0": {
"ParsedownExtra": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "An extension of Parsedown that adds support for Markdown Extra.",
"homepage": "https://github.com/erusev/parsedown-extra",
"keywords": [
"markdown",
"markdown extra",
"parsedown",
"parser"
],
"time": "2015-11-01T10:19:22+00:00"
},
{
"name": "mnapoli/front-yaml",
"version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/mnapoli/FrontYAML.git",
"reference": "24070ace8b741247bb3161cbb38ecc541268b296"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mnapoli/FrontYAML/zipball/24070ace8b741247bb3161cbb38ecc541268b296",
"reference": "24070ace8b741247bb3161cbb38ecc541268b296",
"shasum": ""
},
"require": {
"erusev/parsedown": "~1.0",
"php": ">=5.4.0",
"symfony/yaml": "~2.1|^3.0|^4.0"
},
"require-dev": {
"league/commonmark": "~0.7",
"phpunit/phpunit": "~4.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Mni\\FrontYAML\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"time": "2017-10-29T19:29:55+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "82ebae02209c21113908c229e9883c419720738a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
"reference": "82ebae02209c21113908c229e9883c419720738a",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/yaml",
"version": "v4.3.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "c60ecf5ba842324433b46f58dc7afc4487dbab99"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/c60ecf5ba842324433b46f58dc7afc4487dbab99",
"reference": "c60ecf5ba842324433b46f58dc7afc4487dbab99",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/polyfill-ctype": "~1.8"
},
"conflict": {
"symfony/console": "<3.4"
},
"require-dev": {
"symfony/console": "~3.4|~4.0"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2019-04-06T14:04:46+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}

18
vendor/tildeverse/wiki/src/Parser.php vendored Normal file
View File

@ -0,0 +1,18 @@
<?php
namespace Tildeverse\Wiki;
use Mni\FrontYAML;
class Parser implements FrontYAML\Markdown\MarkdownParser {
public function __construct() {
$this->mdparser = new WikiParsedown();
}
public function parse($markdown) {
return $this->mdparser->text($markdown);
}
public static function factory() {
return new FrontYAML\Parser(null, new Parser());
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace Tildeverse\Wiki;
class WikiParsedown extends \ParsedownExtra {
protected function blockHeader($line) {
$header = parent::blockHeader($line);
if (!isset($header)) {
return null;
}
$id = preg_replace('/[^a-z0-9]/', '-', strtolower($header['element']['text']));
$header['element']['attributes']['id'] = $id;
$header['element']['text'] =
'<small><a class="text-muted" href="#' . $id . '"><i class="fa fa-link"></i></a></small> '
. $header['element']['text'];
return $header;
}
protected function blockTable($line, array $block = null) {
$table = parent::blockTable($line, $block);
if (!isset($table)) {
return null;
}
$table['element']['attributes']['class'] = "table table-striped";
return $table;
}
}