使用Parsedown替换Typecho自带的Markdown解析库,所以在Parsedown下扩展语法,首先在functions.php加载Parsedown

class theme_plugin{
    public static function markdown($text){
        require_once 'Parsedown.php'; // Parsedown.php文件路径
        require_once 'ParsedownExtra.php'; // ParsedownExtra.php文件路径
        require_once 'ParsedownExtraPlugin.php'; // ParsedownExtraPlugin.php文件路径
        $parsedown = new ParsedownExtraPlugin();
        return $parsedown->setBreaksEnabled(true)->text($text);
    }
}

ParsedownExtraPlugin.php中新增以下代码

<?php

class ParsedownExtraPlugin extends ParsedownExtra {
    public function __construct()
    {
        parent::__construct();
        $this->InlineTypes['{'][] = 'Card';
        $this->inlineMarkerList .= '{';
    }

    protected function inlineCard($Excerpt)
    {
        if (preg_match('/^{card\((.*),(.*),(.*)\)}$/', $Excerpt['text'], $matches)) {
            $Element = array(
                'name' => 'a',
                'attributes' => array('href' => trim($matches[3]),'title' => trim($matches[1]),'class' => 'post-card'),
                'handler' => 'elements',
                'text' => array(
                    array(
                        'name' => 'b',
                        'handler' => 'line',
                        'text' => trim($matches[1]),
                    ),
                    array(
                        'name' => 'span',
                        'handler' => 'elements',
                        'text' => array(
                            array(
                                'name' => 'i',
                                'handler' => 'line',
                                'attributes' => array('class' => 'ci-link'),
                                'text' => '',
                            ),
                            array(
                                'name' => 'i',
                                'handler' => 'line',
                                'text' => trim($matches[2]),
                            ),
                        ),
                    ),
                ),
            );

            return array(
                'extent' => strlen($matches[0]),
                'element' => $Element,
            );
        }
    }
}
{card(Aciuz, aciuz.com, https://www.aciuz.com)}