var links = document.links, i = 0, md = [];
for (var len = links.length; i < len; i++) {
var link = links[i];
md.push("[" + link.innerHTML.replace(/\[/g,'\\[').replace(/\]/g,'\\]') + "](" + link.href + ")");
}
console.log(md.join(' \n'))