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

feat: support custom attributes for external links in markdown #356

Closed
wants to merge 2 commits into from

Conversation

ulivz
Copy link
Member

@ulivz ulivz commented May 7, 2018

Summary

This PR is to support following format to add custom attributes for ONLY external links, internal link will keep the old behaviors.

[link-text]((querystring)link)

example 1

  • Input:
[custom domain]((target=_self&class=my-link)http://surge.sh/)
  • Output:
<a href="http://surge.sh/" target="_self" rel="noopener noreferrer" class="my-link">custom domain</a>

example 2

[custom domain]((target=&rel=)http://surge.sh/)

It will be rendered as:

<a href="http://surge.sh/">custom domain</a>

example 3

[custom domain](http://surge.sh/)

It will be rendered as:

<a href="http://surge.sh/" target="_blank" rel="noopener noreferrer">surge</a>

So this PR is fully downward compatible.

cc @meteorlxy @ycmjason

@ulivz
Copy link
Member Author

ulivz commented May 7, 2018

Will add doc later.

@ycmjason
Copy link
Contributor

ycmjason commented May 7, 2018

Just my opinion 😄

I understand that you want to make markdown links more flexible 👍, but I have a feeling that this makes things a little bit too complex? If I were to type the querystring, it is probably easier for me to type html:

<a href="https://github.com">hi</a>

I think this feature request is legitimate and in my opinion the best solution would be having a global config that switches all links. For special cases, just let the user type <a> tags.

What do you think?

@mathiasbynens
Copy link

I think my request in #186 is entirely orthogonal to this proposal.

To clarify, #186 is asking for a way to disable the automatic addition of target="_blank" rel="…" to external links. I don’t need fine-grained control over attributes on links. I just want some kind of configuration setting that I can toggle to stop these attributes from appearing, without having to change my Markdown source files.

@ulivz
Copy link
Member Author

ulivz commented May 8, 2018

@ycmjason It's truly making things more complicated, I agree with your opinion 👍

@mathiasbynens Excuse me, I just misunderstood your proposal and thought that you might need fine-grained control 😅

Closing it and go #357 to continue.

@ulivz ulivz closed this May 8, 2018
@ulivz ulivz deleted the 186-link-attributes branch May 9, 2018 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants