Redirect external links to new tab
2015. 05. 17.
As Pelican can use Markdown to render it's contents, and Markdown doesn't support control over the hyperlink target attribute, you were forced to write your external links and references manually. Or not?

Hopefully, there is a simple javascript hack, that can redirect your external links to a new blank tab.

All the credits go to Austin and to his stackoverflow post. I am just a happy user of this method :)

$('a').each(function() {
   var a = new RegExp('/' + window.location.host + '/');
   if(!a.test(this.href)) {
       $(this).click(function(event) {
           event.preventDefault();
           event.stopPropagation();
           window.open(this.href, '_blank');
       });
   }
});

The method just works. Nothing fancy about it, it does what is supposed to do. Thank you Austin!

Discussion