如何自定义php-markdown链接语法

时间:2012-08-03 03:55:09

标签: php markdown

链接可以通过以下方式定义:

[foo](http://foo)
//or
[foo][1]


[1]:http://foo

如何自定义php-markdown,以便您可以选择是rel="nofollow"还是[foo](!http://foo "this is the title")?像

这样的东西

!

其中rel="nofollow"表示{{1}}归因?

1 个答案:

答案 0 :(得分:4)

对于参考链接,修改line 733周围的行(在撰写本文时)以添加nofollow(如果适用)。对于内联链接,请修改line 752

参考链接代码目前如下所示:

$url = $this->urls[$link_id];
$url = $this->encodeAttribute($url);

$result = "<a href=\"$url\"";
if ( isset( $this->titles[$link_id] ) ) {
    $title = $this->titles[$link_id];
    $title = $this->encodeAttribute($title);
    $result .=  " title=\"$title\"";
}

$link_text = $this->runSpanGamut($link_text);
$result .= ">$link_text</a>";
$result = $this->hashPart($result);

内联链接代码看起来很相似。您需要添加$url!开头的检查,如果是,请将其删除并将rel="nofollow"放在$result的正确位置。

相关问题