简介
markdown是一款比HTML更轻量更容易编写的标记语言,主要用于排版文章,用最简单的方式格式化文章,不需要更多繁琐的操作即可达到美化文章的目的,让作者专心于写作!
众多博客系统,社区都是采用的Markdown格式撰写,比如大家熟知的Github,简书。
根据使用的工具或平台的不一致,效果可能会有所差异,支持程度也不尽相同,本文使用Typora编辑,建议大家使用此编辑器进行查看。
标题
标题使用1~6个#表示,分别对应<h1>~<h6>
如
# This is an H1
## This is an H2
### This is an H3
#### This is an H4
##### This is an H5
###### This is an H6
生成:
This is an H1
This is an H2
This is an H3
This is an H4
This is an H5
This is an H6
引用
引用使用>表示
如
> This is a blockquote with two paragraphs. This is first paragraph.
>
> This is second pragraph.Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
> This is another blockquote with one paragraph. There is three empty line to seperate two blockquote.
生成:
This is a blockquote with two paragraphs. This is first paragraph.
This is second pragraph.Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
This is another blockquote with one paragraph. There is three empty line to seperate two blockquote.
列表
列表使用\*或\-开始,表示无序列表,使用数字开头表示有序列表
如
## un-ordered list
* Red
* Green
* Blue
## ordered list
1. Red
2. Green
3. Blue
生成:
un-ordered list
- Red
- Green
- Blue
ordered list
- Red
- Green
- Blue
任务列表
任务列表使用一对方括号表示[]
如
- [ ] a task list item
- [ ] list syntax required
- [ ] normal **formatting**, @mentions, #1234 refs
- [ ] incomplete
- [x] completed
生成:
- [ ] a task list item
- [ ] list syntax required
- [ ] normal formatting, @mentions, #1234 refs
- [ ] incomplete
- [x] completed
代码块
行内代码块使用一对反引号表示\`,代码块使用三个反引号\`\`\`加上对应的语言使用
如
inline-block-code:
`code`
block-code:
```javascript
function test() {
console.log("notice the blank line before this function?");
}
```
```ruby
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
```
生成:
inline-block-code:
code
block-code:
function test() {
console.log("notice the blank line before this function?");
}
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
表格
不多说,自己领悟
如
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
| Left-Aligned | Center Aligned | Right Aligned |
| :------------ |:---------------:| -----:|
| col 3 is | some wordy text | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
生成:
First Header | Second Header |
---|---|
Content Cell | Content Cell |
Content Cell | Content Cell |
Left-Aligned | Center Aligned | Right Aligned |
---|---|---|
col 3 is | some wordy text | $1600 |
col 2 is | centered | $12 |
zebra stripes | are neat | $1 |
粗体、斜体
使用\*或\_包裹的文字
如
*single asterisks*
_single underscores_
生成:
single asterisks
single underscores
链接
如
This is [an example](http://example.com/ "Title") inline link.
[This link](http://example.net/) has no title attribute.
生成:
This is an example inline link.
This link has no title attribute.
图片
如:
![](/path/to/img.jpg)
![Alt text](http://upload-images.jianshu.io/upload_images/2617247-3839830c44afdbb5.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
生成:
水平分隔线
---
生成:
代码高亮
==highlight==
生成:
==highlight==
本文只是介绍了一些小编常用的语法,Markdown还用很多高级语法,比如数学表达式,流程图,Emoji等等,这里就不一一细说了,有兴趣的童鞋可以自己查阅一下~