Markdown支持两种形式的链接语法:行内式和参考式两种形式。

而我们打开所生产的超链接,默认是在本窗口打开的,为了有更好的阅读体验,我们往往希望在新窗口。 要想让Typecho的文章中链接加上“_blank”,也有很多种方法,比如通过jQuery在网页搜索标签,为其添加新窗口属性。 下面这种方式是直接修改Typecho程序源码,来实现: 在\var\CommonMark\HtmlRenderer.php 搜索

case CommonMark_Element_InlineElement::TYPE_LINK:
$attrs['href'] = $this->escape($inline->getAttribute('destination'), true);
if ($title = $inline->getAttribute('title')) {
    $attrs['title'] = $this->escape($title, true);
}

return $this->inTags('a', $attrs, $this->renderInlines($inline->getAttribute('label')));

在return前加上下面这段代码:

$attrs['target'] = '_blank'; // 给链接增加_blank属性