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

{:target="_blank"} in front of every link provided in the contributing.md #625

Closed
zahyaah opened this issue Oct 5, 2022 · 7 comments
Closed

Comments

@zahyaah
Copy link

zahyaah commented Oct 5, 2022

When clicked on the any of the links, it should open up in a new tab.

image

image

image

@zahyaah zahyaah closed this as completed Oct 5, 2022
@zahyaah zahyaah reopened this Oct 5, 2022
@zahyaah
Copy link
Author

zahyaah commented Oct 5, 2022

I tried the following, but I'm not able to get the required output.

Can @crweiner help me out with this issue?
image

@VocalFan
Copy link

VocalFan commented Oct 5, 2022

It's simply impossible in Github's Markdown. However, the website does use the {:target="_blank"} in the MD file to open a new tab.

@zahyaah
Copy link
Author

zahyaah commented Oct 5, 2022

So, shall I remove the {:target="_blank"} from the contributing.md file?
@Mou-Ikkai
@crweiner

@VocalFan
Copy link

VocalFan commented Oct 5, 2022

So, shall I remove the {:target="_blank"} from the contributing.md file? @Mou-Ikkai @crweiner

No! Because that'd remove the ability for it to open a new tab in the website! x3

@crweiner
Copy link
Owner

crweiner commented Oct 5, 2022

Hello @Mou-Ikkai and @zahyaah! 👋

@Mou-Ikkai is correct. GitHub-flavored markdown does not use any target URL variable, even when writing links in HTML <a> tags. So, any Markdown (or HTML) links when clicked on from GitHub.com will not open in a new tab, or take advantage of any other URL variable. Thus, when you look at the new Index, Contributing, or List md files on GitHub.com itself, you'll see the {target...} attribute. When the site is parsed by Netlify to build the MkDocs pages into HTML from MD, that build does take the URL target into account.

Why is this not something you may have noticed in previous versions of the Swag List?

The Swag List used to be built upon Jekyll and the URLs were re-written (replaced) to include the target="_blank" attribute right here, see PR #366.

To the best of my knowledge, MkDocs and the Material theme required adding the attribute list extensions for Python Markdown and following the Python Markdown spec. Also, see here for further discussion.

TL;DR: It's correct the way it is, due to differences in how markdown is parsed between GitHub.com's rendering and MkDocs. Consider viewing anything in the /docs folder as "raw" markdown, and what's on the live site as the way it's intended to look. Until there is an elegant solution to this in MkDocs, such as a plugin that'll re-write the URLs when the site is built, it'll have to look like this for now. 🤷

Very good question, @zahyaah! I hope this answers it. And thank you very much to @Mou-Ikkai for jumping in to help! 🥇

Hope you all continue to have a great Hacktoberfest! 🎃

@crweiner crweiner closed this as completed Oct 5, 2022
@zahyaah
Copy link
Author

zahyaah commented Oct 6, 2022

@crweiner Thank you so much for explaining me : )

@crweiner
Copy link
Owner

crweiner commented Oct 7, 2022

Hello again @zahyaah and @Mou-Ikkai!

I just added a new Python extension to the repo that'll automatically add the target=_"blank" attribute when MkDocs/Netlify builds the live site without having to specify it manually anymore. 🎉 See PR #659 .

So, now the .md files in this repo are much easier to read, as GitHub will not leave in the {:target="_blank"} after the URLs when browsing on GitHub.com.

Keep in mind that GitHub still won't actually open any links in new tabs, but now you wont see an ugly {:target="_blank"} after each link if you're browsing the repo from here.

So much cleaner now here on GitHub and your IDE of choice! 😄 Let me know if you have any questions!

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

No branches or pull requests

3 participants