Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Markdown open a new window link [duplicate]

Tags:

markdown

People also ask

How do I open a link in new tab with markdown?

Albert Kim just discovered one way to make links open in new browser tabs for R Markdown users: you can add an attribute target="_blank" after a link, e.g., [example website](https://example.com){target="_blank"} .

How do I make a link open in a new tab in github?

Use the Kramdown processor instead of GFM will allow you to add {:target="_blank" rel="noopener"} to markdown links to tell the browser to open link in new tab.

How do I add a new line in markdown?

In a Markdown file or widget, enter two spaces before the line break, and then select Enter to begin a new paragraph. Example - Markdown file or widget: Add two spaces before the end of the line, and then select **Enter**.

How do you make a link open in a new tab CSS?

How to Open Hyperlinks in a New Browser Tab or Window. The short answer is: just add a target="_blank" attribute to your links (anchor tags). Now when your visitors click that link, it will open in a new window or tab (depending on which web browser they are using and how they configured that browser).


There is no such feature in markdown, however you can always use HTML inside markdown:

<a href="http://example.com/" target="_blank">example</a>

As suggested by this answer:

[link](url){:target="_blank"}

Works for jekyll or more specifically kramdown, which is a superset of markdown, as part of Jekyll's (default) configuration. But not for plain markdown. ^_^


Using sed

If one would like to do this systematically for all external links, CSS is no option. However, one could run the following sed command once the (X)HTML has been created from Markdown:

sed -i 's|href="http|target="_blank" href="http|g' index.html

This can be further automated in a single workflow when a Makefile with build instructions is employed.

PS: This answer was written at a time when extension link_attributes was not yet available in Pandoc.


It is very dependent of the engine that you use for generating html files. If you are using Hugo for generating htmls you have to write down like this:

<a href="https://example.com" target="_blank" rel="noopener"><span>Example Text</span> </a>.