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 { class Pastedown extends ParsedownExtra {
public function __construct() { public function __construct() {
$this->BlockTypes['>'] = ['Greentext']; unset($this->BlockTypes['>']);
$this->InlineTypes['>'] = ['Greentext'];
array_unshift($this->BlockTypes['<'], 'Redtext'); 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)) if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
{ {
$Block = array( $Block = array(
'element' => array( 'markup' => "<span class=\"greentext\">" . pp_html_escape($matches[0]) . "</span>",
'name' => 'span', 'extent' => strlen($matches[0])
'attributes' => [
'class' => 'greentext'
],
'handler' => 'line',
'text' => $matches[0],
),
); );
return $Block; return $Block;
} }
} }
protected function blockRedtext($Line) protected function inlineRedtext($Line)
{ {
if (preg_match('/^<[ ]?(.*)/', $Line['text'], $matches)) if (preg_match('/^<[ ]?(.*)/', $Line['text'], $matches))
{ {
$Block = array( $Block = array(
'element' => array( 'markup' => "<span class=\"redtext\">" . pp_html_escape($matches[0]) . "</span>",
'name' => 'span', 'extent' => strlen($matches[0])
'handler' => 'line',
'attributes' => [
'class' => 'redtext'
],
'text' => $matches[0],
),
); );
return $Block; return $Block;
} }
} }
protected function blockPurpletext($Line) protected function inlinePurpletext($Line)
{ {
if (preg_match('/^@[ ]?(.*)/', $Line['text'], $matches)) if (preg_match('/^@[ ]?(.*)/', $Line['text'], $matches))
{ {
$Block = array( $Block = array(
'element' => array( 'markup' => "<span class=\"purpletext\">" . pp_html_escape($matches[0]) . "</span>",
'name' => 'span', 'extent' => strlen($matches[0])
'handler' => 'line',
'attributes' => [
'class' => 'purpletext'
],
'text' => $matches[0],
),
); );
return $Block; 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. // Embed view after highlighting is applied so that $p_code is syntax highlighted as it should be.
if (isset($_GET['embed'])) { if (isset($_GET['embed'])) {
embedView($paste->id, $paste->title, $p_content, $title); embedView($paste->id, $paste->title, $p_content, $site_name);
exit(); exit();
} }

View file

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

View file

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