Links Rendered by Marked.js Open in New Tab? (Markdown Previewer Project)

Links Rendered by Marked.js Open in New Tab? (Markdown Previewer Project)


Hi Coders!

Here’s the (optional) instruction from the Markdown Previewer Project that I’m grappling with:

When I click a link rendered by my markdown previewer, the link is opened up in a new tab (HINT: read the Marked.js docs for this one!).

The main Marked.js doc, their advanced configurations page, and their extensibility page all don’t have anything about “link,” “target,” or “tab” – search terms I used. And in Marked’s demo, when I click on a link, it opens in the same page.

Any advice for getting more out of these docs? Should I be looking out for more subtle clues?

If not, I’ll write my own function to take care of it. :stuck_out_tongue_closed_eyes:



I think this might be an oversight, and should possibly have been removed from the challenge - see this issue:

Possibly @vipatron knows more about it


Perfect! Thanks Dan. That answers it. That instruction should indeed be removed. Good to know :smile:


It works in the sample site for that challenge.


It seems like this optional instruction has been removed from the test, but in case someone may need this feature: it can be be done by

var renderer = new marked.Renderer(); = function(href, title, text) {
    var link =, href, title, text);
    return link.replace("<a","<a target='_blank' ");
    renderer: renderer

See details in marked’s this PR


Sorry to resurrect such an old post, but I’m working on this project right now and I have 2 questions:

1: In the example project this code is used: = function (href, title, text) {
  return `<a target="_blank" href="${href}">${text}` + '</a>';

The results seem the same; is one somehow better than the other?

2: The “new tab” feature seems to work even though I didn’t include the marked.setOptions for renderer:renderer. Is this a side-effect of using the above code?