chobie / php-sundown

php-sundown is just simple wrapper of sundown
Other
137 stars 16 forks source link

Autolink extension target="_blank" #31

Closed zd-dalibor closed 11 years ago

zd-dalibor commented 11 years ago

Is there any way to tell autolink extension to generate link with target="_blank"

chobie commented 11 years ago

you can override autolink method like this.

<?php
class Sample extends  \Sundown\Render\HTML
{
    public function autolink($link, $type)
    {
        return sprintf('<a href="%s" target="_blank">%s</a>', $link, $link);
    }
}

$md = new \Sundown\Markdown(new \Sample, array("autolink"=>true));
echo $md->render("visit http://www.google.com");
# <p>visit <a href="http://www.google.com" target="_blank">http://www.google.com</a></p>

see also https://github.com/chobie/php-sundown/blob/development/docs/Render.md

zd-dalibor commented 11 years ago

I will try this.

zd-dalibor commented 11 years ago

@chobie Yes, this does the trick. Thanks.