. md File Markdown Syntax description

Source: Internet
Author: User
Tags movable type

Markdown Syntax Instructions (Simplified Chinese version)/(click to see Quick Start)
    • Overview
      • Purpose
      • Compatible HTML
      • Automatic conversion of special characters
    • Chunk element
      • Paragraphs and line breaks
      • Title
      • Chunk reference
      • List
      • code block
      • Divider Line
    • Section element
      • Link
      • Emphasize
      • Code
      • Image
    • Other
      • Back slash
      • Auto Link
    • Thank
    • Markdown Free Editor
Overview Purpose

Markdown's goal is to achieve "easy-to-read and easy-to-write".

Readability, in any case, is the most important. A file written in Markdown format should be published directly in plain text and will not appear to be composed of many labels or formatting instructions. The Markdown syntax is influenced by a number of existing text-to-html formats, including Setext, ATX, Textile, Restructuredtext, Grutatext, and Ettext, and the greatest source of inspiration is the format of plain text e-mail.

In short, Markdown's grammar is made up of a number of symbols, which are carefully selected for a glance. For example, by adding an asterisk to both sides of the text, it looks like a * accent *. The list of Markdown looks, well, is the list. Markdown's chunk references seem to really look like a reference to a piece of text, as you've seen in an email.

Compatible HTML

The goal of the Markdown syntax is to become a writing language for the web.

Markdown does not want to replace HTML, or even close to it, it has very few grammatical types, only a small part of the HTML tag. Markdown's idea is not to make HTML documents easier to write. In my opinion, HTML is easy to write. Markdown's philosophy is that it makes it easier to read, write, and change documents. HTML is a published format, and Markdown is a form of writing . In this way, Markdown's format syntax covers only the range that plain text can cover.

Tags that are not covered by Markdown can be written directly in the document using HTML. No additional markup is required. This is either HTML or Markdown; just add the tag directly.

Only some HTML block elements, such as,,, and so on, must be separated from the rest of the <div> <table> <pre> <p> content area in front and back, and also require that their start and end tags cannot be indented with tabs or spaces. The Markdown generator is smart enough not to include unnecessary labels on HTML block tags <p> .

As an example, add an HTML table to the Markdown file:

这是一个普通段落。<table>    <tr>        <td>Foo</td>    </tr></table>这是另一个普通段落。

Note that the Markdown format syntax between HTML chunk tags will not be processed. For example, you can use the Markdown style in HTML chunks *强调* without effect.

The section of HTML (in-line) tags, such as, <span> <cite> <del> can be used in Markdown paragraphs, lists or headings. According to personal habits, you can even use HTML tags instead of Markdown format. For example, if you prefer HTML <a> or tags, you can use these tags directly instead of Markdown the links provided or the image tag syntax.

Unlike HTML block tags, the Markdown syntax is valid between HTML section tags.

Automatic conversion of special characters

In the HTML file, there are two characters that require special handling: < and & . <symbols are used for starting tags, and & symbols are used to mark HTML entities, and if you just want to show the prototypes of those characters, you have to use the form of the entity, like the &lt; and &amp; .

&Characters are especially tortured by Web document writers, and if you want to hit " AT&T ", you have to write " AT&amp;T ." The characters in the URL are & also converted. For example, you would link to:

http://images.google.com/images?num=30&q=larry+bird

You have to write the URL translation as:

http://images.google.com/images?num=30&amp;q=larry+bird

To be placed in the properties of the link tag href . Needless to say, this is easy to ignore, which is probably the largest number of errors checked by the HTML standard test.

Markdown allows you to naturally write characters that need to be converted to be handled by it. If you use a & character that is part of an HTML character entity, it will remain intact, otherwise it will be converted to &amp ;

So if you want to insert a copyright symbol in the document © , you can write:

&copy;

Markdown will keep it still. And if you write:

AT&T

Markdown will convert it to:

AT&amp;T

A similar situation also occurs on the < symbol, because Markdown allows for compatible HTML, and if you are < using the symbol as a delimiter for HTML tags, then Markdown does not convert it, but if you write:

4 < 5

Markdown will convert it to:

4 &lt; 5

However, it is important to note that within the code range, whether inline or chunk, < and & two symbols are bound to be converted to HTML entities, this feature allows you to easily write HTML code in Markdown (and HTML relative to HTML syntax, you want to < convert all and all & into HTML entities, in order to write HTML code in the HTML file. )

Chunk element paragraphs and line breaks

A Markdown paragraph consists of one or more contiguous lines of text that have more than one empty line before and after it (the definition of a blank line is that the display appears to be empty and is treated as a blank line.) For example, if a row contains only spaces and tabs, the row is also considered a blank line. Normal paragraphs should not be indented with spaces or tabs.

"Consists of one or more contiguous lines of text" it actually implies that Markdown allows forced line breaks within a paragraph (inserting newline characters), which is different from most other text-to-html formats (including the movable Type "convert line breaks"option), the other formats will turn each newline character into a <br /> label.

If you really want to rely on Markdown to insert <br /> a label, press the two or more spaces at the insertion point and enter.

Yes, it takes more than a few things (extra space) to produce <br /> , but simply "every line change to <br /> " method is not suitable in Markdown, Markdown in the e-mail block reference and multi-paragraph list in the use of line to typesetting, not only better use, but also more Easy to read.

Title

Markdown supports two headings of syntax, Class Setext, and Class ATX form.

The class Setext form is in the form of a bottom line, using = (highest-order headings) and - (second-order headings), for example:

This is an H1=============This is an H2-------------

Any number of = and - all can have effect.

The class Atx form is inserted at the beginning of the line 1 to 6 # , corresponding to the title 1 to 6 order, for example:

# 这是 H1## 这是 H2###### 这是 H6

You can selectively "close" the title of the ATX style, which is purely aesthetic, and if you feel comfortable, you can add it at the end # of the line, and the number of lines at the end is # not the same as the beginning (the number of wells in the beginning determines the order of the title):

# 这是 H1 ### 这是 H2 ##### 这是 H3 ######
Chunk Reference Blockquotes

Markdown tag block references are used in similar email > references. If you're familiar with the introductory part of an email message, you'll know how to create a chunk reference in the Markdown file, which would look like you broke the line yourself first, and then put it at the front of each line > :

> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.> > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse> id sem consectetuer libero luctus adipiscing.

Markdown also allows you to be lazy only the first line of the entire paragraph is preceded by > :

> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisseid sem consectetuer libero luctus adipiscing.

Chunk references can be nested (for example, references within references), as long as they are based on a different number of levels > :

> This is the first level of quoting.>> > This is nested blockquote.>> Back to the first level.

Other Markdown grammars can also be used within the referenced chunks, including headings, lists, code blocks, and so on:

> ## 这是一个标题。> > 1.   这是第一行列表项。> 2.   这是第二行列表项。> > 给出一些例子代码:> >     return shell_exec("echo $input | $markdown_script");

Any decent text editor makes it easy to create email-based references. For example, in BBEdit, you can select text and then choose Add Reference Hierarchy from the menu.

List

Markdown supports both sequential and unordered lists.

Unordered lists use asterisks, plus signs, or minus signs as list markers:

*   Red*   Green*   Blue

Equivalent to:

+   Red+   Green+   Blue

is also equivalent to:

-   Red-   Green-   Blue

The sequence table uses numbers followed by a period:

1.  Bird2.  McHale3.  Parish

It is important that the number you use on the list tag does not affect the output HTML result, which is generated by the HTML tag:

<ol><li>Bird</li><li>McHale</li><li>Parish</li></ol>

If your list tag is written as:

1.  Bird1.  McHale1.  Parish

or even:

3. Bird1. McHale8. Parish

You will get exactly the same HTML output. The point is that you can make the list numbers of the Markdown files the same as the output, or you can be lazy and you don't have to worry about the correctness of the numbers at all.

If you use lazy writing, it is recommended that the first project is preferably from 1. Start, because Markdown may support the Start property with the sequence table in the future.

List item markers are usually left on the leftmost side, but can also be indented, up to 3 spaces, followed by at least one space or tab after the item tag.

To make the list look prettier, you can sort the content in a fixed indentation:

*   Lorem ipsum dolor sit amet, consectetuer adipiscing elit.    Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,    viverra nec, fringilla in, laoreet vitae, risus.*   Donec sit amet nisl. Aliquam semper ipsum sit amet velit.    Suspendisse id sem consectetuer libero luctus adipiscing.

But if you're lazy, that's fine:

*   Lorem ipsum dolor sit amet, consectetuer adipiscing elit.Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,viverra nec, fringilla in, laoreet vitae, risus.*   Donec sit amet nisl. Aliquam semper ipsum sit amet velit.Suspendisse id sem consectetuer libero luctus adipiscing.

If the list items are separated by blank lines, Markdown will wrap the item contents in the output HTML <p> , for example:

*   Bird*   Magic

will be converted to:

<ul><li>Bird</li><li>Magic</li></ul>

But this:

*   Bird*   Magic

will be converted to:

<ul><li><p>Bird</p></li><li><p>Magic</p></li></ul>

A list item can contain more than one paragraph, and each paragraph under each item must be indented 4 spaces or 1 tabs:

1.  This is a list item with two paragraphs. Lorem ipsum dolor    sit amet, consectetuer adipiscing elit. Aliquam hendrerit    mi posuere lectus.    Vestibulum enim wisi, viverra nec, fringilla in, laoreet    vitae, risus. Donec sit amet nisl. Aliquam semper ipsum    sit amet velit.2.  Suspendisse id sem consectetuer libero luctus adipiscing.

If you have indentation on every line, it looks like a lot, of course, again, if you're lazy, Markdown also allows:

*   This is a list item with two paragraphs.    This is the second paragraph in the list item. You‘reonly required to indent the first line. Lorem ipsum dolorsit amet, consectetuer adipiscing elit.*   Another item in the same list.

If you want to put a reference within a list item, you > need to indent it:

*   A list item with a blockquote:    > This is a blockquote    > inside a list item.

If you want to put a block of code, the chunk needs to be indented two times , which is 8 spaces or 2 tabs:

*   一列表项包含一个列表区块:        <代码写在这>

Of course, the list of items is likely to be inadvertently generated, as in the following notation:

1986. What a great season.

In other words, the number-period-blank appears at the beginning of the line, so you can avoid this situation by adding a backslash to the period.

1986\. What a great season.
code block

Program-related writing or tag language source code will usually have a well-written code block, usually these blocks we do not want it to the general paragraph file layout, but as the original appearance, Markdown will use <pre> and <code> tags to the code block package up.

To create a code block in Markdown is simple, simply indent 4 spaces or 1 tab characters, for example, the following input:

这是一个普通段落:    这是一个代码区块。

Markdown will be converted into:

<p>这是一个普通段落:</p><pre><code>这是一个代码区块。</code></pre>

This first-order indent (4 spaces or 1 tabs) will be removed, for example:

Here is an example of AppleScript:    tell application "Foo"        beep    end tell

will be converted to:

<p>Here is an example of AppleScript:</p><pre><code>tell application "Foo"    beepend tell</code></pre>

A block of code continues until the line (or end of the file) is not indented.

In the code block, & < and > will automatically turn into an HTML entity, this way makes it very easy to use the Markdown Insert sample HTML source code, only need to copy the paste, plus indentation on it, the rest of the Markdown will help you handle, For example:

    <div class="footer">        &copy; 2004 Foo Corporation    </div>

will be converted to:

<pre><code>&lt;div class="footer"&gt;    &amp;copy; 2004 Foo Corporation&lt;/div&gt;</code></pre>

In code chunks, the general Markdown syntax is not converted, as asterisks are just asterisks, which means you can easily write Markdown grammar-related files in the Markdown syntax.

Divider Line

You can create a divider line with more than three asterisks, minus signs, and bottom lines in a row, and there's nothing else in the line. You can also insert a space between an asterisk or a minus sign. Separate lines can be created for each of the following types of notation:

* * *********- - ----------------------------------------
Section element link

Markdown supports two forms of link syntax: inline and two forms of reference .

Either way, the link text is marked with [square brackets].

To create a inline link, just follow the parentheses around the square brackets and insert the URL link, if you want to add a link to the title text, as long as the URL behind, use double quotation marks to wrap the title text, for example:

This is [an example](http://example.com/ "Title") inline link.[This link](http://example.net/) has no title attribute.

Will produce:

<p>This is <a href="http://example.com/" title="Title">an example</a> inline link.</p><p><a href="http://example.net/">This link</a> has notitle attribute.</p>

If you are a resource to be linked to the same host, you can use a relative path:

See my [About](/about/) page for details.

The reference link is followed by another square bracket after the parenthesis of the linked text, and the second square bracket is filled with a tag that identifies the link:

This is [an example][id] reference-style link.

Optionally, you can add a space between the two square brackets:

This is [an example] [id] reference-style link.

Then, at any point in the file, you can define the linked content of this tag:

[id]: http://example.com/  "Optional Title Here"

The link content definition is in the form of:

    • Square brackets (You can selectively add up to three spaces in the front to indent), enter the link text inside
    • Then a colon
    • followed by more than one space or tab
    • Then the URL of the link
    • Optionally, the title content can be enclosed in single quotes, double quotes, or parentheses.

The following three links are defined in the same way:

[foo]: http://example.com/  "Optional Title Here"[foo]: http://example.com/  ‘Optional Title Here‘[foo]: http://example.com/  (Optional Title Here)

Note: There is a known issue that markdown.pl 1.0.1 will ignore the single quotation marks wrapped up in the link title.

Link URLs can also be wrapped in angle brackets:

[id]: 

You can also put the title property on the next line, you can also add some indentation, if the URL is too long, this will be more beautiful:

[id]: http://example.com/longish/path/to/resource/here "Optional Title Here"

The URL definition is used only when the link is generated and does not appear directly in the file.

Link discrimination tags can have letters, numbers, blanks, and punctuation, but are not case-sensitive, so the following two links are the same:

[link text][a][link text][A]

The implicit Link Markup feature allows you to omit the specified link tag, in which case the link tag is treated as the link text, with an implicit link tag as long as the link text is appended with an empty square bracket, if you want to have "Google" linked to Google.com, you can simplify it into:

[Google][]

Then define the link content:

[Google]: http://google.com/

Because linked text may contain whitespace, this simplified type of tag may contain multiple words:

Visit [Daring Fireball][] for more information.

Then define the link:

[Daring Fireball]: http://daringfireball.net/

The definition of a link can be placed anywhere in the file, and I prefer to place it directly behind the link, or you can put it on the last side of the file, just like a note.

Here is an example of a reference link:

I get 10 times more traffic from [Google] [1] than from[Yahoo] [2] or [MSN] [3]. [1]: http://google.com/ "Google" [2]: http://search.yahoo.com/ "Yahoo Search" [3]: http://search.msn.com/ "MSN Search"

If you change to write with the link name:

I get 10 times more traffic from [Google][] than from[Yahoo][] or [MSN][]. [google]: http://google.com/ "Google" [yahoo]: http://search.yahoo.com/ "Yahoo Search" [msn]: http://search.msn.com/ "MSN Search"

Both of the above will produce the following HTML.

<p>I get 10 times more traffic from <a href="http://google.com/"title="Google">Google</a> than from<a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>

The following is a Markdown file with the same piece of content written in line, provided as a comparison:

I get 10 times more traffic from [Google](http://google.com/ "Google")than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or[MSN](http://search.msn.com/ "MSN Search").

Reference links In fact, it is not the focus of it is better to write, but it is better to read, compared to the above example, the use of reference to the article itself only 81 characters, but in the form of the line will be increased to 176 characters, if it is written in plain HTML, there will be 234 characters, in the HTML format, There are more labels than text.

Using the Markdown reference link, you can make the file more like the final result of the browser, allowing you to move some tag-related metadata outside the paragraph, and you can add links without interrupting the reading sensation of the article.

Emphasize

Markdown uses the asterisk ( * ) and the bottom line ( _ ) as a sign of the underlined words, and * the words that are or surrounded by them are turned into labels, _ <em> with two or more wrapped words, which are then converted * _ <strong> to, for example:

*single asterisks*_single underscores_**double asterisks**__double underscores__

Will turn into:

<em>single asterisks</em><em>single underscores</em><strong>double asterisks</strong><strong>double underscores</strong>

You can use the style you like, the only limit is, what symbol you use to open the tag, you will end with what symbol.

Emphasis can also be inserted directly in the middle of the text:

un*frigging*believable

But if you * _ have blank spaces on both sides, they will only be treated as normal symbols .

If you want to insert a normal asterisk or bottom line directly before or after the text, you can use a backslash:

\*this text is surrounded by literal asterisks\*
Code

If you want to mark a small piece of inline code, you can wrap it up () in an inverted quotation mark ` , for example:

Use the `printf()` function.

Will produce:

<p>Use the <code>printf()</code> function.</p>

If you want to insert an anti-quote inside a section of code, you can use multiple anti-quotes to open and close the code segment:

``There is a literal backtick (`) here.``

This syntax will produce:

<p><code>There is a literal backtick (`) here.</code></p>

The starting and ending ends of the code section can be placed in a blank, one after the beginning and one at the end, so you can insert the back quotation marks at the beginning of the section:

A single backtick in a code span: `` ` ``A backtick-delimited string in a code span: `` `foo` ``

Will produce:

<p>A single backtick in a code span: <code>`</code></p><p>A backtick-delimited string in a code span: <code>`foo`</code></p>

Within the Code section, & and angle brackets are automatically turned into HTML entities, which makes inserting HTML primitives easy, Markdown will take this paragraph:

Please don‘t use any `<blink>` tags.

Into

<p>Please don‘t use any <code>&lt;blink&gt;</code> tags.</p>

You can also write this:

`&#8212;` is the decimal-encoded equivalent of `&mdash;`.

To produce:

<p><code>&amp;#8212;</code> is the decimal-encodedequivalent of <code>&amp;mdash;</code>.</p>
Image

Obviously, it is difficult to design a "natural" syntax to insert a picture in a plain text application.

Markdown uses a syntax similar to a link to mark a picture, and also allows two styles: inline and reference .

The inline image syntax looks like this:

![Alt text](/path/to/img.jpg)![Alt text](/path/to/img.jpg "Optional title")

Detailed descriptions are as follows:

    • An exclamation of!
    • followed by a square bracket, where the alternative text of the slice
    • Then an ordinary bracket, inside the URL of the film, and finally can be enclosed in quotation marks and add the optional ' title ' text.

The reference image syntax looks like this:

![Alt text][id]

"id" is the name of the picture reference, and the image reference is defined in the same way as the link reference:

[id]: url/to/image  "Optional title attribute"

So far, Markdown has not been able to specify the width of the picture, and if you need it, you can use the normal label.

Other automatic links

Markdown supports the use of short, automatic links to address URLs and e-mail boxes, and Markdown automatically turns them into links as long as they are wrapped in angle brackets. The link text of the general URL is the same as the link address, for example:

Markdown will switch to:

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

The automatic link of the postal address is very similar, just Markdown will do an encoding conversion process, the text character into a 16-digit HTML entity, this format can fool some bad mail collection robot, for example:

<[email protected]>

Markdown will turn into:

<a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>

Inside the browser, this string (in fact <a href="mailto:[email protected]">[email protected]</a> ) becomes a clickable "[email protected]" link.

(This practice can fool a lot of robots, but not all of them, but it's better than nothing.) In any case, open your mailbox will eventually attract advertising letters. )

Back slash

Markdown can use backslashes to insert symbols that have other meanings in the syntax, such as: if you want to emphasize the effect (but not the label) with an asterisk next to the text <em> , you can precede the asterisk with backslashes:

\*literal asterisks\*

Markdown supports the following symbols preceded by a backslash to help insert a normal symbol:

\   反斜线`   反引号*   星号_   底线{}  花括号[]  方括号()  括弧#   井字号+   加号-   减号.   英文句点!   惊叹号

Original link: http://wowubuntu.com/markdown/

. md File Markdown Syntax description

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.