-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What would be the correct way to make links open in external window? #144
Comments
Have a look at my pull request: #129 The renderer feature would be a good choice to do such thing. It didn't has a |
Maybe you should use jQuery and just |
If you're open to modifying your version of marked, you can just redefine the template that it uses for autolinking (a GFM feature). Right now, the line is here: https://github.com/chjj/marked/blob/master/lib/marked.js#L578 |
I implemented it as below.
|
Thanks for the code block @icoxfog417 — I looked it over a little more and also saw an example from the docs for overriding renderer methods, and the code can more simply be written as such: var renderer = new marked.Renderer();
renderer.link = function(href, title, text) {
var link = marked.Renderer.prototype.link.call(this, href, title, text);
return link.replace("<a","<a target='_blank' ");
};
marked.setOptions({
renderer: renderer
}); |
Closes statamic/ideas#671. Solution based on markedjs/marked#144 (comment)
Closes statamic/ideas#671. Solution based on markedjs/marked#144 (comment)
Hi gents,
I'm attempting to coerce marked (great lib! thanks for sharing!) into making all links in the markdown content open in external windows.
What would be best practice for this? Can I use the
lexer
to manipulate the tokens in some way that would accomplish this before they go into the parser?Cheers,
The text was updated successfully, but these errors were encountered: