From 82cd8bd676e8e8b83e9d08edcf4b5d14db267c73 Mon Sep 17 00:00:00 2001 From: Floorb <132411956+Neetpone@users.noreply.github.com> Date: Sat, 27 May 2023 11:52:09 -0400 Subject: [PATCH] Revert "Added better greentext function to parsedown" This reverts commit f8f1f162 --- includes/Pastedown.php | 41 +++++++-------------- public/paste.php | 2 +- public/theme/bulma/css/bulma.min.css | 24 +++++++++++-- vendor/erusev/parsedown/Parsedown.php | 52 +++++++++++---------------- 4 files changed, 56 insertions(+), 63 deletions(-) diff --git a/includes/Pastedown.php b/includes/Pastedown.php index 3a8bdc1..5ab930b 100644 --- a/includes/Pastedown.php +++ b/includes/Pastedown.php @@ -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' => "" . pp_html_escape($matches[0]) . "", + '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' => "" . pp_html_escape($matches[0]) . "", + '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' => "" . pp_html_escape($matches[0]) . "", + 'extent' => strlen($matches[0]) ); return $Block; diff --git a/public/paste.php b/public/paste.php index 4f1c230..e536d8c 100644 --- a/public/paste.php +++ b/public/paste.php @@ -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(); } diff --git a/public/theme/bulma/css/bulma.min.css b/public/theme/bulma/css/bulma.min.css index 079083a..a53e332 100644 --- a/public/theme/bulma/css/bulma.min.css +++ b/public/theme/bulma/css/bulma.min.css @@ -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 { diff --git a/vendor/erusev/parsedown/Parsedown.php b/vendor/erusev/parsedown/Parsedown.php index 077a5e0..1b9d6d5 100644 --- a/vendor/erusev/parsedown/Parsedown.php +++ b/vendor/erusev/parsedown/Parsedown.php @@ -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