Markdown中超链接增加_blank的方法

很遗憾,无法在语法上实现,只能通过额外的的JS代码实现,比如:

var links = document.links;
for (var i = 0; i < links.length; i++) {
    if (!links[i].target) {
        if (
            links[i].hostname !== window.location.hostname || 
            /\.(?!html?)([a-z]{0,3}|[a-zt]{0,4})$/.test(links[i].pathname)
        ) {
            links[i].target = '_blank';
        } 
    }
}

 

参考:

https://stackoverflow.com/questions/5014632/how-can-i-parse-a-yaml-file-from-a-linux-shell-script

https://stackoverflow.com/questions/4425198/can-i-create-links-with-target-blank-in-markdown

http://www.xuebuyuan.com/2867893.html

posted @ 2017-12-26 23:12  EasonJim  阅读(626)  评论(0编辑  收藏  举报