Markdown syntax description (Simplified Chinese Version)

Source: Internet
Author: User
Tags movable type

Markdown syntax description (Simplified Chinese Version)

NOTE: This is Simplelified Chinese Edition Document of Markdown Syntax. If you are seeking for English Edition Document. Please refer to Markdown: Syntax.

Disclaimer: This document is derived from the Traditional Chinese version (fork). On this basis, the Traditional Chinese version is converted to the Simplified Chinese version, and the appropriate retouching is performed. This document is written in Markdown syntax. You can view its source files here. 「 Here are the original files in the Traditional Chinese version .」 -- By @ riku

This project is hosted on GitCafe. Please use "" and "merge requests" to help improve this project.

Markdown syntax description (Simplified Chinese Version)/(click to view Quick Start)
  • Overview
    • Purpose
    • HTML compatibility
    • Automatic conversion of special characters
  • Block Element
    • Section and line feed
    • Title
    • Block reference
    • List
    • Code block
    • Separation line
  • Section Element
    • Link
    • Emphasize
    • Code
    • Image
  • Others
    • Backslash
    • Automatic link
  • Thanks
  • Markdown free editor
Overview Purpose

Markdown aims to achieve "easy to read and write 」.

Readability is the most important in any case. A file written in Markdown format should be directly published in plain text, and does not seem to consist of many labels or format instructions. The Markdown syntax is influenced by some text-to-HTML formats, including Setext, atx, Textile, reStructuredText, Grutatext, and EtText. The biggest source of inspiration is the text email format.

In short, the Markdown syntax is composed of all the symbols. These symbols are carefully selected, and their functions are clear at a glance. For example, adding an asterisk on both sides of the text looks like * Emphasizing *. The Markdown list looks like, well, it is the list. The Markdown block reference looks like a text reference, as you have seen in an email.

HTML compatibility

The goal of the Markdown syntax is to become a network-orientedWritingLanguage.

Markdown does not want to replace HTML, and is not even similar to it. It has very few syntax types and only corresponds to a small part of HTML Tag. Concept of MarkdownNoTo make HTML documents easier to write. In my opinion, HTML is easy to write. Markdown makes it easier to read, write, and modify documents. HTML isReleaseMarkdown isWritingFormat. In this way, the Markdown format syntax only covers the scope that can be covered by plain text.

Tags that are not covered by Markdown can be written in HTML directly in the document. You do not need to add HTML or Markdown labels. You only need to add tags directly.

Only some HTML block elements are restricted-for example<div>,<table>,<pre>,<p>And other labels. Empty lines must be added before and after the labels and must be separated from other content areas. The start and end labels must not be indented by tabs or spaces. The Markdown generator is smart enough not to add unnecessary tags to HTML blocks.<p>Label.

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

This is a common section. <Table> <tr> <td> Foo </td> </tr> </table> is another common section.

Note that the Markdown format syntax between HTML block tags will not be processed. For example, if you use the Markdown style in the HTML block* Emphasis *Will be ineffective.

The HTML segment (in-row) label is as follows:<span>,<cite>,<del>You can use it in the Markdown section, list, or title. According to your personal habits, you can even use HTML tags instead of Markdown. Example: If you prefer HTML<a>OrTags, which can be used directly without the link or Image Tag syntax provided by Markdown.

Unlike HTML block tags, The Markdown syntax is effective between HTML block tags.

Automatic conversion of special characters

In an HTML file, two characters need special processing:<And&.<Symbol is used to start a tag,&Symbols are used to mark HTML objects. If you only want to display the prototype of these characters, you must use the Entity form, such&lt;And&amp;.

&The characters especially make the network document writers suffer. If you want to play 「AT&TYou must write 「AT&amp;T」. However&Character conversion is also required. For example, you want to link:

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

You must convert the URL:

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

Can be placed in the Link labelhrefAttribute. Needless to say, this is easy to ignore. This may also be the most common error detected by the HTML standard check.

Markdown allows you to naturally write characters, which must be converted. If you use&A character is a part of an HTML character entity. It is retained as it is, otherwise it is converted&amp;.

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

&copy;

Markdown will keep it unchanged. If you write:

AT&T

Markdown converts it:

AT&amp;T

Similar situations also occur<Symbol, because Markdown allows HTML compatibility.<When a symbol is used as the identifier of an HTML Tag, Markdown will not convert it, but if you write:

4 < 5

Markdown converts it:

4 &lt; 5

However, it should be noted that within the code range, whether in-row or block,<And&Both symbolsYesIt will be converted into HTML entities. This feature allows you to easily use Markdown to write HTML code (in HTML syntax, You need to convert all<And&To write HTML code in the HTML file .)

Block Element section and line feed

A Markdown Section is composed of one or more consecutive lines of text. It must have more than one blank line before and after it, it is considered as a blank line. For example, if a row contains only spaces and tabs, the row is also considered as a blank row ). Common paragraphs should not be indented by spaces or tabs.

The sentence "composed of one or more consecutive lines of text" actually implies that Markdown allows forced line breaks (insert line breaks) in a paragraph ), this feature is different from most other text-to-HTML formats (including the "Convert Line Breaks" option of Movable Type). Other formats Convert each Line break<br />Label.

If youIndeedYou want to rely on Markdown to insert<br />Then, press two or more spaces in the insert field and press Enter.

Indeed, it takes a little more time (with more space) to generate<br />But simply, "Each line feed is converted<br />This method is not suitable for Markdown. In Markdown, the e-mail-type block reference and multi-section list are not only easier to use but also easier to read when using line breaks for formatting.

Title

Markdown supports the syntax of two titles, in the form of Setext and atx.

The form of Setext is the form of bottom line, using=(The highest level title) and-(Second-level title), for example:

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

Any number=And-Can be effective.

In the Atx-like format, insert 1 to 6 records at the beginning of the row.#, Corresponding to level 1 to Level 6 of the title, for example:

# This is H1 ## this is H2 #### this is H6

You can choose to "close" the title of the atx style. This is purely beautiful. If you think it looks more comfortable, you can add it at the end of the line.#And at the end of the line#The number does not need to be the same as that of the beginning (the number of well characters at the beginning of the line determines the order of the title ):

# This is H1 ### this is H2 #### this is H3 ######
Block reference Blockquotes

Markdown mark block reference is used in similar email>. If you are still familiar with the introduction in the email, you will know how to create a block reference in the Markdown file. It looks like you have broken the line first, add>:

> 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 and add only at the beginning of the first line of the entire paragraph>:

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

Block references can be nested (for example, references in a reference), as long as different numbers>:

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

You can also use other Markdown syntaxes in the referenced block, including the title, list, and code block:

### This is a title.> > 1. This is the first line list item.> 2. This is the list item of the second row.> > Some sample codes are provided:> return shell_exec ("echo $ input | $ markdown_script ");

Any decent text editor can easily create email-type references. For example, in BBEdit, you can select text and then selectAdd reference class.

List

Markdown supports ordered and Unordered Lists.

Unordered Lists are marked with asterisks, plus signs, or minus signs:

*   Red*   Green*   Blue

Equivalent:

+   Red+   Green+   Blue

It is also equivalent:

-   Red-   Green-   Blue

The ordered list uses numbers followed by an English sentence:

1.  Bird2.  McHale3.  Parish

It is very important that the number you use on the list tag does not affect the output HTML result. The HTML Tag generated in the above list is:

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

If your list tag is written:

1.  Bird1.  McHale1.  Parish

Or even:

3. Bird1. McHale8. Parish

You will get the same HTML output. The point is that you can make the list number of the Markdown file the same as the output result, or you are a little lazy, you do not need to care about the correctness of the number.

If you are using lazy writing, it is recommended that you start from 1. For the first project, because Markdown may support the start attribute of the ordered list in the future.

The list project tag is usually placed on the leftmost, but it can also be indented. A maximum of three spaces are allowed. The project tag must be followed by at least one space or tab.

To make the list look more beautiful, you can organize the content with 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 are lazy, you can:

*   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 use<p>For example:

*   Bird*   Magic

Will be converted:

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

But this:

*   Bird*   Magic

Will be converted:

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

A list project can contain multiple paragraphs. Each section under a project must be indented with four spaces or one tab:

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 each line is indented, you will look much more optimistic. Of course, again, if you are very 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 include references in the list project>Indent:

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

If you want to place a code block, the block needs to be indented.Twice, That is, 8 spaces or 2 tabs:

* A list item contains a list block: <the code is written here>

Of course, the project list may be accidentally generated, as shown in the following code:

1986. What a great season.

In other words, that is, the first line appearsDigit-period-BlankTo avoid this situation, you can add a backslash before the sentence.

1986\. What a great season.
Code block

The original code of Program-related writing or tag language usually has a well-formed code block, which we do not want to typeset in the form of common paragraph files, as shown in the original figure, Markdown will use<pre>And<code>Label to package the code block.

To create a code block in Markdown, you only need to indent four spaces or one tab. For example, the following input:

This is a common section: This is a code block.

Markdown is converted:

<P> This is a common section: </p> <pre> <code> This is a code block. </Code> </pre>

The indentation of the first order of each line (4 spaces or 1 tab) will be removed, for example:

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

Will be converted:

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

A code block continues until the line without indentation (or the end of the file ).

In the code block,&,<And>The object is automatically converted to an HTML object. This method makes it very easy for you to use Markdown to insert the original HTML code of the sample. You only need to copy and paste the original code, and then add indentation, the rest of Markdown will help you deal with it, for example:

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

Will be converted:

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

In code blocks, the general Markdown syntax is not converted. For example, an asterisk is just an asterisk, which means you can easily write Markdown syntax-related files.

Separation line

You can use more than three asterisks, minus signs, and bottom lines in a row to create a separator. There is no other line. You can also insert spaces between asterisks or minus signs. You can create a separation line for each of the following writing methods:

* * *********- - ----------------------------------------
Segment element Link

Markdown supports two forms of link Syntax:InlineAndReference.

No matter which one, the link text is marked with [square brackets.

CreateInlineAs long as the square brackets are followed by parentheses and the URL link is inserted. If you want to add the title Text of the link, you only need to wrap the title text behind the URL with double quotation marks, for example:

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

Will generate:

<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 want to link to resources on the same host, you can use the relative path:

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

ReferenceThe link is followed by another square brackets of the link text, and the second square brackets should be filled with the mark used to identify the link:

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

You can also add a space between two square brackets:

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

Next, you can define the link content of the tag wherever the file is:

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

The link content is defined as follows:

  • Square brackets (you can add up to three spaces to indent the brackets). Enter the link text in the brackets.
  • Followed by a colon
  • Followed by more than one space or tab
  • URL
  • Choose the title content, which can be enclosed by single quotation marks, double quotation marks, or arc.

The definitions of the following three links are the same:

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

Note: One known problem is that Markdown. pl 1.0.1 ignores the link title enclosed in single quotes.

Link URLs can also be wrapped in angle brackets:

[id]: 

You can also place the title attribute in the next line, or add some indentation. If the URL is too long, it will look better:

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

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

The link identification tag can contain letters, numbers, spaces, and punctuation characters,NoIt is case sensitive, so the following two links are the same:

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

Implicit link markThe link tag function allows you to omit the specified link tag. In this case, the link tag is considered to be equivalent to the link text. To use the implicit link tag, add an empty square brackets after the link text, if you want to link "Google" to google.com, You can simplify it:

[Google][]

Then define the link content:

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

Because the link text may contain spaces, the simplified Mark 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 in any part of the file. I prefer to directly put it behind the section where the link appears. You can also put it at the end of the file, just like an annotation.

The following is an example of 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 it is changed to 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"

The preceding two methods generate 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 for writing the same paragraph of content in the line, which is provided for 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").

In fact, the reference link does not focus on writing it well, but on reading it well. In the example above, the reference article itself only contains 81 characters, however, in the line format, it will increase to 176 characters. If it is written in pure HTML format, there will be 234 characters. in HTML format, there are more labels than text.

By using the reference link of Markdown, you can make the file more like the final result of the browser, so that you can move some metadata related to the mark out of the paragraph text, you can add links to prevent reading interruption.

Emphasize

Markdown (*) And bottom line (_) Is used as a symbol to mark words.*Or_The words that are surrounded will be converted to use.<em>Surrounded by tags, with two*Or_The package will be converted<strong>For example:

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

Will be converted:

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

You can use whatever style you like. The only restriction is that you need to end the process by opening a tag with any symbol.

The emphasis can also be directly inserted in the middle of the text:

un*frigging*believable

But if your*And_If there is blank space on both sides, they will only be treated as common symbols.

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

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

To mark a small line of code, you can enclose it in reverse quotation marks (`), For example:

Use the `printf()` function.

Will generate:

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

If you want to insert backquotes in the Code section, you can use multiple backquotes to enable and end the Code Section:

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

This syntax produces:

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

Both the start and end ends of the code segment can be blank, followed by the start and the end, so that you can insert backquotes at the beginning of the code segment:

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

Will generate:

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

In the code section,&And angle brackets are automatically converted into HTML entities, which makes it easy to insert the original HTML code. Markdown will insert the following section:

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

Convert:

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

You can also write:

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

To generate:

<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 in a text-only application to insert an image.

Markdown uses a syntax similar to the link to mark an image. It also allows two styles:InlineAndReference.

The row-Based Picture syntax looks like:

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

The details are as follows:

  • An exclamation point!
  • Next, a square brackets are used to place the replaced text in the slice.
  • Next, we will use a regular bracket to enclose the slice URL, and then enclose it with quotation marks and add the selective 'title' text.

The reference image syntax looks like this:

![Alt text][id]

"Id" is the name of the image reference. The definition of the image reference is the same as that of the link reference:

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

So far, Markdown has no way to specify the width and height of the image. If you need it, you can use the commonLabel.

Other automatic links

Markdown supports processing URLs and email mailboxes in a short form of automatic links. Markdown will automatically convert them into links as long as they are wrapped in angle brackets. Generally, the link text of a URL is the same as that of a URL. For example:

Markdown will be converted:

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

The automatic link of the mail address is similar, but Markdown will first perform an encoding conversion process to convert the text character into the html object of the hexadecimal code, this format can be used to confuse some bad address collection robots, such:

<address@example.com>

Markdown is converted:

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

In the browser, this string (actually<a href="mailto:address@example.com">address@example.com</a>) Will become a clickable "address@example.com" link.

(Although this method can fool a lot of robots, it cannot be all blocked, but it is always better than nothing. In any case, opening your mailbox will eventually attract advertisement letters .)

Backslash

Markdown can use a backslash to insert symbols with other meanings in the syntax. For example, if you want to add an asterisk next to the text to emphasize the effect (but you don't need<em>Label), you can add a backslash before the asterisk:

\*literal asterisks\*

Markdown supports adding a backslash before the following symbols to help insert common symbols:

\ Backslash 'quotation marks * asterisks _ bottom line {} brackets [] square brackets () arc # Well font size + plus sign-minus sign. English sentence! Exclamation point
Thanks

Thanks to leafy7382 for the help of translation, hlb and Randylien for the draft, ethantw's standard Chinese character format, ・ CSS Reset, and WM for returning text errors.

Thanks to fenprace and addv.

Markdown free editor

Windows Platform

  • MarkdownPad
  • MarkPad

Linux platform

  • ReText

Mac Platform

  • Mou

Online Editor

  • Markable. in
  • Dillinger. io

Browser plugin

  • MaDe (Chrome)

Advanced Applications

  • Sublime Text 2 + MarkdownEditing/tutorial

*** For better Markdown free editor recommendations, please submit your feedback here. Thank you!

This article permanently updates the link address:

Related Article

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.