Markdown open a new window link

2019-01-16 06:46发布

问题:

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? Thanks

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

回答1:

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

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


回答2:

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



回答3:

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.



标签: markdown