Markdown open a new window link

Markdown

Markdown Problem Overview


I'm trying to edit a website which uses a modx cms, and it's using Markdown. Now I would like to open a new link into another window.

Is it possible?

The Link [Registration](http://www.registration.com)

Markdown Solutions


Solution 1 - Markdown

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

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

Solution 2 - Markdown

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. ^_^

Solution 3 - 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.

Solution 4 - Markdown

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>.

Solution 5 - Markdown

You can edit the generated markup and add

target = "_blank"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontintincutesView Question on Stackoverflow
Solution 1 - MarkdownVladimir KeleshevView Answer on Stackoverflow
Solution 2 - MarkdownshellbyeView Answer on Stackoverflow
Solution 3 - MarkdownSerge StroobandtView Answer on Stackoverflow
Solution 4 - MarkdownHenarasView Answer on Stackoverflow
Solution 5 - MarkdownOsinachiView Answer on Stackoverflow