erusev / parsedown

Better Markdown Parser in PHP
https://parsedown.org
MIT License
14.79k stars 1.13k forks source link

stop blockquote from initializing for Alerts #879

Closed Meng-Heng closed 1 month ago

Meng-Heng commented 2 months ago

Hi! Is there a way to override the blockquote?

public function __construct()
    {
       $this->BlockTypes['>'][] = 'Alert';
    }

Result through PHPUnit:

<blockquote>
<p>[!IMPORTANT]</p>
</blockquote>R

Does the > trigger the blockquote conversion? But I need it to get the Alerts to work:

> [!NOTE]
> Useful information that users should know, even when skimming content.

Please support on this.

taufik-nurrohman commented 2 months ago
class ParsedownExtension extends Parsedown {
    protected function blockQuote($Block) {
        if (preg_match('/^>\s*\[!note\]/i', $Block['text'])) {
            return /* Alert markup definition */;
        }
        return parent::blockQuote($Block);
    }
}
Meng-Heng commented 2 months ago

@taufik-nurrohman Thanks, It works!