Primo Committ

This commit is contained in:
paoloar77
2024-05-07 12:17:25 +02:00
commit e73d0e5113
7204 changed files with 884387 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
<?php
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
* - (c) John MacFarlane
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\CommonMark\Inline\Element;
use League\CommonMark\Node\Node;
/**
* @method children() AbstractInline[]
*/
abstract class AbstractInline extends Node
{
/**
* @var array<string, mixed>
*
* Used for storage of arbitrary data
*/
public $data = [];
public function isContainer(): bool
{
return false;
}
/**
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function getData(string $key, $default = null)
{
return isset($this->data[$key]) ? $this->data[$key] : $default;
}
}

View File

@@ -0,0 +1,53 @@
<?php
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
* - (c) John MacFarlane
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\CommonMark\Inline\Element;
class AbstractStringContainer extends AbstractInline
{
/**
* @var string
*/
protected $content = '';
/**
* @param string $contents
* @param array<string, mixed> $data
*/
public function __construct(string $contents = '', array $data = [])
{
$this->content = $contents;
$this->data = $data;
}
/**
* @return string
*/
public function getContent(): string
{
return $this->content;
}
/**
* @param string $contents
*
* @return $this
*/
public function setContent(string $contents)
{
$this->content = $contents;
return $this;
}
}

View File

@@ -0,0 +1,53 @@
<?php
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
* - (c) John MacFarlane
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\CommonMark\Inline\Element;
abstract class AbstractWebResource extends AbstractInline
{
/**
* @var string
*/
protected $url;
public function __construct(string $url)
{
$this->url = $url;
}
/**
* @return string
*/
public function getUrl(): string
{
return $this->url;
}
/**
* @param string $url
*
* @return $this
*/
public function setUrl(string $url)
{
$this->url = $url;
return $this;
}
public function isContainer(): bool
{
return true;
}
}

View File

@@ -0,0 +1,19 @@
<?php
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
* - (c) John MacFarlane
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\CommonMark\Inline\Element;
class Code extends AbstractStringContainer
{
}

View File

@@ -0,0 +1,23 @@
<?php
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
* - (c) John MacFarlane
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\CommonMark\Inline\Element;
class Emphasis extends AbstractInline
{
public function isContainer(): bool
{
return true;
}
}

View File

@@ -0,0 +1,19 @@
<?php
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
* - (c) John MacFarlane
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\CommonMark\Inline\Element;
class HtmlInline extends AbstractStringContainer
{
}

View File

@@ -0,0 +1,31 @@
<?php
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
* - (c) John MacFarlane
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\CommonMark\Inline\Element;
class Image extends AbstractWebResource
{
public function __construct(string $url, ?string $label = null, ?string $title = null)
{
parent::__construct($url);
if (!empty($label)) {
$this->appendChild(new Text($label));
}
if (!empty($title)) {
$this->data['title'] = $title;
}
}
}

View File

@@ -0,0 +1,31 @@
<?php
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
* - (c) John MacFarlane
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\CommonMark\Inline\Element;
class Link extends AbstractWebResource
{
public function __construct(string $url, ?string $label = null, ?string $title = null)
{
parent::__construct($url);
if (!empty($label)) {
$this->appendChild(new Text($label));
}
if (!empty($title)) {
$this->data['title'] = $title;
}
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
* - (c) John MacFarlane
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\CommonMark\Inline\Element;
class Newline extends AbstractInline
{
// Any changes to these constants should be reflected in .phpstorm.meta.php
const HARDBREAK = 0;
const SOFTBREAK = 1;
/** @var int */
protected $type;
public function __construct(int $breakType = self::HARDBREAK)
{
$this->type = $breakType;
}
public function getType(): int
{
return $this->type;
}
}

View File

@@ -0,0 +1,23 @@
<?php
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
* - (c) John MacFarlane
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\CommonMark\Inline\Element;
class Strong extends AbstractInline
{
public function isContainer(): bool
{
return true;
}
}

View File

@@ -0,0 +1,28 @@
<?php
/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <colinodell@gmail.com>
*
* Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
* - (c) John MacFarlane
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace League\CommonMark\Inline\Element;
class Text extends AbstractStringContainer
{
/**
* @param string $character
*
* @return void
*/
public function append(string $character)
{
$this->content .= $character;
}
}