crweiner/hacktoberfest-swag-list

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

zahyaah opened this issue ยท 7 comments

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

image

image

image

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

Can @crweiner help me out with this issue?
image

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.

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

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

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 Thank you so much for explaining me : )

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!