Markdown tutorial (reproduced Collection)

Basic grammar

title

Markdown supports six levels of headings, corresponding to the html tags h1 ~ h6

# h1
## h2
### h3
#### h4
##### h5
###### h6

Markup above effects are as follows:

h1

h2

h3

h4

H5
h6

In addition, Markdown supports an alternative form of title to show a form, which is similar to Setext form of markup language, use underscores to control text size

这是一级标题
===
这是二级标题
---

The title this way only two forms of treatment, i.e., a title and subheadings. Unfortunately, the book does not support this simple syntax. Therefore, we used a map to show the effect of:


 
 

This approach is common in the open source project Github above, the obvious disadvantages are: the limited size of the text control level.

Paragraph and block references

Keep in mind that, Markdown is actually written in an easy to plain text, but joined the label text rendering part of it. It will still eventually be converted to html tags, so use Markdown segmentation is very simple, leave at least one blank line before and after can be.

And the other more common demand is that we may want to emphasize certain words be processed. Markdown provides a special symbol> for the first paragraph for emphasis, the emphasized portion of text will be highlighted

> 这段文字将被高亮显示...

Above mark display is as follows:

This text will be highlighted ...

Insert a link or picture

Markdown for link and picture processing is relatively simple, you can use the following syntax mark

[点击跳转至百度](http://www.baidu.com) ![图片](https://upload-images.jianshu.io/upload_images/703764-605e3cc2ecb664f6.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 

Above mark display is as follows:

Click to jump to Baidu

 
image

 

Note: The only difference between the reference images and links is at the forefront add an exclamation point.

List

Markdown supports ordered list and unordered list in two forms:

  • * Unordered list or use the + or - logo
  • Ordered lists use numbers plus ID, such as: 1.
* 黄瓜
* 玉米
* 茄子

+ 黄瓜
+ 玉米
+ 茄子

- 黄瓜
- 玉米
- 茄子

1. 黄瓜
2. 玉米
3. 茄子

Above mark display is as follows:

  • cucumber
  • corn
  • eggplant
  • cucumber
  • corn
  • eggplant
  • cucumber
  • corn
  • eggplant
  1. cucumber
  2. corn
  3. eggplant

Note: The more interesting here is that, for an ordered list, Markdown will focus only numbered your first project. For example: if the first item number is 3, and so on, should be the second item 4, it will eventually appear as 3,4,5. And if you specify the first number, followed by the specified error number does not matter, Markdown will only care about your first item number.

Using a list of some of the considerations

If you include multiple paragraphs in a single list item, in order to ensure the normal rendering, * between paragraphs initials and four spaces must be preserved

*    段落一

     小段一
*    段落二

     小段二

Above mark display is as follows:

  • 段落一

    小段一

  • 段落二

    小段二

另外,如果在列表中加入了区块引用,区域引用标记符也需要缩进4个空格

* 段落一
    > 区块标记一
* 段落二
    > 区块标记二
  • 段落一

    区块标记一

  • 段落二

    区块标记二

注:记住一个原则,如果在和列表配合使用的时候出现了问题,就缩进一次,四个空格或者一个制表符代表一次缩进。如果一次缩进没有解决问题,那就两次。

分隔线

有时候,为了排版漂亮,可能会加入分隔线。Markdown加入分隔线非常简单,使用下面任意一种形式都可以

***
---


产生分隔线的语法要求比较松,符号之间添加空格也可以。

强调

有时候,我们希望对某一部分文字进行强调,使用*或_包裹即可。使用单一符号标记的效果是斜体,使用两个符号标记的效果是加粗

*这里是斜体*
_这里是斜体_

**这里是加粗**
__这里是加粗__

这里是斜体
这里是斜体

这里是加粗
这里是加粗

高级用法

插入代码块

Markdown在IT圈子里面比较流行的一个重要原因是,它能够轻松漂亮地插入代码。

方法是,使用反引号`进行包裹即可。如果是行内代码引用,使用单个反引号进行包裹

这是一段var x = 3行内代码

如果插入一整段代码,需要至少使用两个以上反引号进行包裹, 看效果:

fun (x: Int, y: Int): Int { return x + y } 

注:很多人不知道怎么输入反引号。在英文模式下,找到键盘最左侧esc键下面的第一个键点击即可。

插入表格

表格是Markdown语法中比较复杂的一个,其语法如下:

表头|条目一|条目二
:---:|:---:|:---: 项目|项目一|项目二 

以上标记显示效果如下:

表头 条目一 条目二
项目 项目一 项目二

注:三个短斜杠左右的冒号用于控制对齐方式,只放置左边冒号表示文字居左,只放置右边冒号表示文字居右,如果两边都放置冒号表示文字居中。

其它

特殊符号处理

Markdown使用反斜杠\插入语法中用到的特殊符号。在Markdown中,主要有以下几种特殊符号需要处理:

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

例如,如果你需要插入反斜杠,就连续输入两个反斜杠即可:\\ => \ 。

注:在内容中输入以上特殊符号的时候一定要注意转义,否则将导致内容显示不全,甚至排版混乱。

如何给文字上色

Students use Markdown is probably the most depressing place can not be added to the color of the text. In fact, the initial goal is pure writing Markdown born. Therefore, it does not consider that the text color. So, simply use Markdown text color has been set can not do that. But you can do this:

  1. First with Markdown editing is complete
  2. Export to html, in the part-manual colors are required to add tags <font color = '# ff0000'> </ font> save.

Markdown software recommended

If you are a Mac user, I recommend that you use open source MacDown :

 
Macdown

 

If you are willing to spend money, then some of the fee-based products is actually better. For example: Byword, Ulysses, Typora and so very good.

Daily use, I use Macdown. Writing a book, I use Ulysses.

A brief summary

Markdown is a simpler than html markup language, which is mainly used for everyday writing. The final conversion by the appropriate editor or script into html for page rendering. If you're a writer or a programmer, Markdown for you it is an essential skill. Markdown really easy to master, as you can see, this article uses such a short space has all the Markdown syntax introduced over.

However, due to limitations basis Markdown syntax, there are some enhanced version for the Markdown syntax. It supports syntax more features, but this is not the scope of our article. If you want to quickly grasp Markdown, very simple, move it!



Author: Ouyang Feng
link: https: //www.jianshu.com/p/335db5716248
Source: Jane books
are copyrighted by the author. Commercial reprint please contact the author authorized, non-commercial reprint please indicate the source.

Guess you like

Origin www.cnblogs.com/limor/p/12082542.html