Skip to content
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

[Patch] Add target="_blank" to links #362

Closed
asbai opened this issue Mar 16, 2017 · 5 comments
Closed

[Patch] Add target="_blank" to links #362

asbai opened this issue Mar 16, 2017 · 5 comments

Comments

@asbai
Copy link

asbai commented Mar 16, 2017

I want all links are opened by a new window, the change is simple:

  1. Under function writeAnchorTag of showdown.subParser:
// ...
    var target = " target=\"_blank\"";
    target = target.replace(showdown.helper.regexes.asteriskAndDash, showdown.helper.escapeCharactersCallback);

    var result = '<a href="' + url + '"' + target;
// ...

This is for normal link ([text](url) form).

  1. Under replaceLink:
// ...
    var target = " target=\"_blank\"";
    target = target.replace(showdown.helper.regexes.asteriskAndDash, showdown.helper.escapeCharactersCallback);

    return '<a href="' + link + '"' + target + '>' + lnkTxt + '</a>' + append;

This one for simple link.

Of course, it would be nice if there is an option to control it (I'm surprised there isn't already one).
:-)

@tivie tivie self-assigned this Mar 18, 2017
@tivie
Copy link
Member

tivie commented Mar 18, 2017

Duplicate of #337 #249 #247 #222

@tivie
Copy link
Member

tivie commented Mar 18, 2017

Since this is a feature that's been requested over and over again, I will add this as a feature

@tivie
Copy link
Member

tivie commented Mar 30, 2017

Should be implemented

@tylerjbainbridge
Copy link

I'm also looking for this fix - how can I use this new fix? Do I have to target a certain version? Sorry if this is a stupid question.

@tivie
Copy link
Member

tivie commented Mar 31, 2017

Use develop branch

@tivie tivie closed this as completed in 50235d6 Apr 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants