How to use angle brackets in URL on Github Flavore

2019-02-19 18:19发布

问题:

I want to use angle brackets in URL on Github Flavor Markdown.

Markdown:

1. Fork it ( http://github.com/<my-github-username>/oooooaaaa/fork )

Expect:

<li>Fork it ( <a href="http://github.com/">http://github.com/&lt;my-github-username&gt;/oooooaaaa/fork</a> )</li>

Actual:

<li>Fork it ( <a href="http://github.com/">http://github.com/</a><my-github-username>/oooooaaaa/fork )</my-github-username></li>

回答1:

Since the angle brackets < and > cannot easily be used (or escaped or encoded) in GitHub Flavored Markdown, one workaround would be to used square brackets:

http://github.com/[my-github-username]/oooooaaaa/fork

That does give the expected result:

a href="http://github.com/">http://github.com/[my-github-username]/oooooaaaa/fork</a>


回答2:

Even this example below works as expected.

http://github.com/(my-github-username)/oooooaaaa/fork



回答3:

Using backslash inside a ()[] construction seems to work. (Tested on GitHub now.) It does not work on SO though.. For example:

1. Fork it ( [http://github.com/\<my-github-username\>/oooooaaaa/fork](http://github.com/\<my-github-username\>/oooooaaaa/fork) )