2023-05-13 23:27:56 -04:00
|
|
|
<?php
|
|
|
|
namespace PonePaste;
|
|
|
|
|
|
|
|
use ParsedownExtra;
|
|
|
|
|
|
|
|
class Pastedown extends ParsedownExtra {
|
|
|
|
public function __construct() {
|
2023-05-27 11:52:09 -04:00
|
|
|
unset($this->BlockTypes['>']);
|
|
|
|
$this->InlineTypes['>'] = ['Greentext'];
|
2023-05-27 12:00:03 -04:00
|
|
|
array_unshift($this->InlineTypes['<'], 'Redtext');
|
2023-05-27 11:52:09 -04:00
|
|
|
$this->InlineTypes['@'] = ['Purpletext'];
|
2023-05-13 23:27:56 -04:00
|
|
|
}
|
|
|
|
|
2023-05-27 11:52:09 -04:00
|
|
|
protected function inlineGreentext($Line)
|
2023-05-13 23:27:56 -04:00
|
|
|
{
|
|
|
|
if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
|
|
|
|
{
|
|
|
|
$Block = array(
|
2023-05-27 11:52:09 -04:00
|
|
|
'markup' => "<span class=\"greentext\">" . pp_html_escape($matches[0]) . "</span>",
|
|
|
|
'extent' => strlen($matches[0])
|
2023-05-13 23:27:56 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
return $Block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-27 11:52:09 -04:00
|
|
|
protected function inlineRedtext($Line)
|
2023-05-13 23:27:56 -04:00
|
|
|
{
|
|
|
|
if (preg_match('/^<[ ]?(.*)/', $Line['text'], $matches))
|
|
|
|
{
|
|
|
|
$Block = array(
|
2023-05-27 11:52:09 -04:00
|
|
|
'markup' => "<span class=\"redtext\">" . pp_html_escape($matches[0]) . "</span>",
|
|
|
|
'extent' => strlen($matches[0])
|
2023-05-13 23:27:56 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
return $Block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-27 11:52:09 -04:00
|
|
|
protected function inlinePurpletext($Line)
|
2023-05-13 23:27:56 -04:00
|
|
|
{
|
|
|
|
if (preg_match('/^@[ ]?(.*)/', $Line['text'], $matches))
|
|
|
|
{
|
|
|
|
$Block = array(
|
2023-05-27 11:52:09 -04:00
|
|
|
'markup' => "<span class=\"purpletext\">" . pp_html_escape($matches[0]) . "</span>",
|
|
|
|
'extent' => strlen($matches[0])
|
2023-05-13 23:27:56 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
return $Block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|