Markdown专题研究_Span系列 1/4: Links 篇

LINKS



two kinds of links in Markdown

Markdown supports two style of links: inline and reference, In both styles, the link text is delimited by [square brackets].

Mark's Notes
for both style, the the "http://" symbol can not be omitted for web-link, otherwise the parser will take it as an exterior file. And consequently clicking the hyperlink will always throw an warning like no such file exist

  • To create an inline link, use a set of regular parentheses immediately after the link text’s closing square bracket. Inside the parentheses, put the URL where you want the link to point, along with an optional title for the link, surrounded in quoteseither single or double, but cannot be omitted or replaced by parenthesis. For example:

    • This is [an example](http://example.com/ "Optional Title") inline link.
    • [This link](http://example.net/) has no title attribute.
      注意嵌套的列表需要前面外加两个空格
  • Reference-style links use a second set of square brackets, inside which you place a label of your choosing to identify the link:

    • This is [an example][id] reference-style link.
      You can optionally use a space to separate the sets of brackets
      Then, anywhere in the document, you define your link label like this, on a line by itself:
      [id]: http://example.com/ "Optional Title"
      Optional title attribute for the link, should be enclosed in double or single quotes, or in parentheses.
      The link URL may, optionally, be surrounded by angle brackets. [id]: "Optional Title Here"

NOTE: There is a known bug in Markdown.pl 1.0.1 which prevents single quotes from being used to delimit link titles.

You can put the title attribute on the next line and use extra spaces or tabs for padding, which tends to look better with longer URLs:
[id]: http://example.com/longish/path/to/resource/here "Optional Title Here"

Summary

for inline style, we use one set of square brackets together with round parenthesis.
for reference style, two sets of square brackets needed.


links' definition

  • Link definitions are only used for creating links during Markdown processing, and are stripped from your document in the HTML output.

  • Link definition names may consist of letters, numbers, spaces, and punctuation — but they are not case sensitive.

  • The implicit link name shortcut allows you to omit the name of the link, in which case the link text itself is used as the name. Just use an empty set of square brackets — e.g., to link the word “Google” to the google.com web site, you could simply write:
    [Google] [ ]
    And then define the link:
    [Google]: http://google.com/
    是支持这一方式的,已验证

    • Because link names may contain spaces, this shortcut even works for multiple words in the link text:
      Visit[Daring Fireball][] for more information.
      And then define the link:
      [Daring Fireball]: http://daringfireball.net/
  • Link definitions can be placed anywhere in your Markdown document. I tend to put them immediately after each paragraph in which they’re used, but if you want, you can put them all at the end of your document, sort of like footnotes.

The point of reference-style links is not that they’re easier to write. The point is that with reference-style links, your document source is vastly more readable.

With Markdown’s reference-style links, a source document much more closely resembles the final output, as rendered in a browser. By allowing you to move the markup-related metadata out of the paragraph, you can add links without interrupting the narrative flow of your prose.

[try back to top](# two kinds of links in Markdown)
[links' definition](# links' definition)

你可能感兴趣的:(Markdown专题研究_Span系列 1/4: Links 篇)