简易Markdown入门上手
Markdown 是一种可以使用普通文本编辑器编写的标记语言,语法简洁明了、学习容易,而且功能比纯文本更强。通过简单的标记语法,它可以使普通文本内容具有一定图文混排格式的排版。因此有很多人用它写博客,写笔记。世界上最流行的几大博客平台都能很好的支持Markdown。也越来越多的论坛,社区开始使用 Markdown 代替传统的文本编辑方式。
Markdown常用语法
标题
标题能显示出文章的结构。行首插入1-6个 # ,每增加一个 # 表示更深入层次的内容,对应到标题的深度由 1-6 阶。
- H1 : # Header 1
- H2 : ## Header 2
- H3 : ### Header 3
- H4 : #### Header 4
- H5 : ##### Header 5
- H6 : ###### Header 6
例子:
Header 1
Header 2
Header 3
Header 4
Header 5
Header 6
文本样式
- 加粗 : **Bold**
- 斜体字 : *Italics*
- 删除线 : ~~text~~
- 列表 : * + - 添加星号(加号、减号)成为一个新的列表项
- 引用 : > 引用内容
- 内嵌代码 : `alert('Hello World');`
- 画水平线 (HR) : --------
例子:
Bold
Italicstext
- 添加星号(加号、减号)成为一个新的列表项
引用内容
alert('Hello World');
链接
行内形式(title 是选择性的):
This is an [example link](http://example.com/ "title").
例子:
This is an example 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"
例子
I get 10 times more traffic from Google than from Yahoo or MSN.
图片
图片的语法和链接很像。
行内形式(title 是选择性的):
![alt text](/path/to/img.jpg "Title")
参考形式:
![alt text][id]
[id]: /path/to/img.jpg "Title"
图片+链接
[![alt text](/path/to/img.jpg "Title")](http://example.com/)
表格
| Left align | Right align | Center align |
|:-----------|------------:|:------------:|
| This | This | This |
| column | column | column |
| will | will | will |
| be | be | be |
| left | right | center |
| aligned | aligned | aligned |
例子:
Left align | Right align | Center align |
---|---|---|
This | This | This |
column | column | column |
will | will | will |
be | be | be |
left | right | center |
aligned | aligned | aligned |
代码块
很多时候写技术文章都要贴出代码块,这里只写一种就是在 后面加上语言,如 \
php.
例子:
```php
function showThumbnail($widget){
$num = rand(1, 3);
switch($num){
case 1: $image_file = "http://ww4.sinaimg.cn/large/7c98397dgw1ezu6ixumi7j218g0g113g.jpg";
break;
case 2: $image_file = "http://ww3.sinaimg.cn/large/7c98397dgw1ezu6jolbsfj218g0h6n8c.jpg";
break;
case 3: $image_file = "http://ww4.sinaimg.cn/large/7c98397dgw1ezu6jeb8lzj218g0g1124.jpg";
break;
}
echo $image_file;
}
```
function showThumbnail($widget){
$num = rand(1, 3);
switch($num){
case 1: $image_file = "http://ww4.sinaimg.cn/large/7c98397dgw1ezu6ixumi7j218g0g113g.jpg";
break;
case 2: $image_file = "http://ww3.sinaimg.cn/large/7c98397dgw1ezu6jolbsfj218g0h6n8c.jpg";
break;
case 3: $image_file = "http://ww4.sinaimg.cn/large/7c98397dgw1ezu6jeb8lzj218g0g1124.jpg";
break;
}
echo $image_file;
}
原样输出
原样输出#>`()等符号,需加反斜杆"\"
例子:\#\>\`\()
#>`()
结束语
简单Markdown上手笔记 大部分是针对Typecho去写的,是自己的知识备忘录,希望也能帮到大家。 ^-^
参考
- help.github.com/articles/github-flavored-markdown
- guides.github.com/features/mastering-markdown
- help.github.com/enterprise/2.1/user/articles/markdown-basics
- wowubuntu.com/markdown
- www.jianshu.com/p/q81RER
- www.jianshu.com/p/7bd23251da0a
- www.markdown.cn/
- www.zybuluo.com/mdeditor#100972
- zh.wikipedia.org/wiki/Markdown
- ibruce.info/2013/11/26/markdown/
- www.gitbook.com/book/gitbookio/markdown/details