Revert "Added better greentext function to parsedown"

This reverts commit f8f1f162
This commit is contained in:
Floorb 2023-05-27 11:52:09 -04:00
parent 66676c75a9
commit 82cd8bd676
4 changed files with 56 additions and 63 deletions

View file

@ -5,62 +5,45 @@ use ParsedownExtra;
class Pastedown extends ParsedownExtra {
public function __construct() {
$this->BlockTypes['>'] = ['Greentext'];
unset($this->BlockTypes['>']);
$this->InlineTypes['>'] = ['Greentext'];
array_unshift($this->BlockTypes['<'], 'Redtext');
$this->BlockTypes['@'] = ['Purpletext'];
$this->InlineTypes['@'] = ['Purpletext'];
}
protected function blockGreentext($Line)
protected function inlineGreentext($Line)
{
if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
{
$Block = array(
'element' => array(
'name' => 'span',
'attributes' => [
'class' => 'greentext'
],
'handler' => 'line',
'text' => $matches[0],
),
'markup' => "<span class=\"greentext\">" . pp_html_escape($matches[0]) . "</span>",
'extent' => strlen($matches[0])
);
return $Block;
}
}
protected function blockRedtext($Line)
protected function inlineRedtext($Line)
{
if (preg_match('/^<[ ]?(.*)/', $Line['text'], $matches))
{
$Block = array(
'element' => array(
'name' => 'span',
'handler' => 'line',
'attributes' => [
'class' => 'redtext'
],
'text' => $matches[0],
),
'markup' => "<span class=\"redtext\">" . pp_html_escape($matches[0]) . "</span>",
'extent' => strlen($matches[0])
);
return $Block;
}
}
protected function blockPurpletext($Line)
protected function inlinePurpletext($Line)
{
if (preg_match('/^@[ ]?(.*)/', $Line['text'], $matches))
{
$Block = array(
'element' => array(
'name' => 'span',
'handler' => 'line',
'attributes' => [
'class' => 'purpletext'
],
'text' => $matches[0],
),
'markup' => "<span class=\"purpletext\">" . pp_html_escape($matches[0]) . "</span>",
'extent' => strlen($matches[0])
);
return $Block;

View file

@ -228,7 +228,7 @@ if ($paste_code === "pastedown" || $paste_code === 'pastedown_old') {
// Embed view after highlighting is applied so that $p_code is syntax highlighted as it should be.
if (isset($_GET['embed'])) {
embedView($paste->id, $paste->title, $p_content, $title);
embedView($paste->id, $paste->title, $p_content, $site_name);
exit();
}

View file

@ -320,6 +320,13 @@ dl,
dt,
fieldset,
figure,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
html,
iframe,
legend,
@ -327,10 +334,23 @@ li,
ol,
p,
pre,
textarea {
textarea,
ul {
margin: 0;
padding: 0;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-size: 100%;
font-weight: 400;
}
ul {
list-style: none;
}
button,
input,
select,
@ -8244,7 +8264,7 @@ a.has-text-link-dark:hover {
background-color: #2160c4 !important;
}
.has-text-info {
color: #3298dc;
color: #3298dc !important;
}
a.has-text-info:focus,
a.has-text-info:hover {

View file

@ -121,15 +121,14 @@ class Parsedown
'8' => array('List'),
'9' => array('List'),
':' => array('Table'),
'<' => array('Comment', 'Markup','Redtext'),
'<' => array('Comment', 'Markup'),
'=' => array('SetextHeader'),
'>' => array('Greentext'),
'>' => array('Quote'),
'[' => array('Reference'),
'_' => array('Rule'),
'`' => array('FencedCode'),
'|' => array('Table'),
'~' => array('FencedCode'),
'@' => array('Purpletext'),
);
# ~
@ -653,13 +652,13 @@ class Parsedown
#
# Quote
protected function blockGreentext($Line)
protected function blockQuote($Line)
{
if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
{
$Block = array(
'element' => array(
'name' => 'greentext',
'name' => 'blockquote',
'handler' => 'lines',
'text' => (array) $matches[1],
),
@ -669,38 +668,29 @@ class Parsedown
}
}
protected function blockRedtext($Line)
protected function blockQuoteContinue($Line, array $Block)
{
if (preg_match('/^<[ ]?(.*)/', $Line['text'], $matches))
if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
{
$Block = array(
'element' => array(
'name' => 'Redtext',
'handler' => 'lines',
'text' => (array) $matches[1],
),
);
if (isset($Block['interrupted']))
{
$Block['element']['text'] []= '';
unset($Block['interrupted']);
}
$Block['element']['text'] []= $matches[1];
return $Block;
}
if ( ! isset($Block['interrupted']))
{
$Block['element']['text'] []= $Line['text'];
return $Block;
}
}
protected function blockPurpletext($Line)
{
if (preg_match('/^@[ ]?(.*)/', $Line['text'], $matches))
{
$Block = array(
'element' => array(
'name' => 'purpletext',
'handler' => 'lines',
'text' => (array) $matches[1],
),
);
return $Block;
}
}
#
# Rule