Markdown 语法笔记

2016-02-29  本文已影响86人  奋斗的蜗牛

Markdown 是一种轻量级的「标记语言」,它的优点很多,目前也被越来越多的写作爱好者,撰稿者广泛使用。看到这里请不要被「标记」、「语言」所迷惑,Markdown 的语法十分简单。常用的标记符号也不超过十个,这种相对于更为复杂的HTML 标记语言来说,Markdown 可谓是十分轻量的,学习成本也不需要太多,且一旦熟悉这种语法规则,会有一劳永逸的效果。

#  H1
##  H2
###  H3
####  H4
#####  H5
######  H6

H1

H2

H3

H4

H5
H6

Setext方式:

一级标题
===
二级标题
---

一级标题

二级标题


*斜体* or _强调_
**加粗** or __加粗__
***粗斜体*** or ___粗斜体___

斜体 or 强调
加粗 or 加粗
粗斜体 or 粗斜体

但是,如果你的 * 和 _ 两边都有空白的话,它们就只会被当成普通的符号:这是一段* 文本强调 *的说明示例。
如果要在文字前后直接插入普通的星号或底线,你可以用反斜线(转义符):*this text is surrounded by literal asterisks*


Unordered 无序列表:

* 无序列表
* 子项
* 子项
 
+ 无序列表
+ 子项
+ 子项

- 无序列表
- 子项
- 子项
  • 无序列表

Ordered 有序列表:

1. 第一行
2. 第二行
3. 第三行
 
1. 第一行
- 第二行
- 第三行
  1. 第一行
  1. 第二行
  2. 第三行
  1. 第一行
- 嵌套列表
 + 嵌套列表
 + 嵌套列表 
   - 嵌套列表
     * 嵌套列表
- 嵌套列表

-+*可循环使用,但符号之后的空格不能少,符号之前的空格也不能少

可有时我们会出现这样的情况,首行内容是以日期或数字开头:2013. 公司年度目标。
为了避免也被转化成有序列表,我们可以在"."前加上反斜杠(转义符):2013\. 公司年度目标。




> 引用

引用

内层符号前的空格必须要

>引用
 >>引用中的引用

引用
引用中的引用


Inline-style 内嵌方式:
[link text](https://www.baidu.com "title text")
Reference-style 引用方式:
[link text][id]
[id]: https://www.mozilla.org "title text"

Relative reference to a repository file 引用存储文件:
[link text](../path/file/readme.text "title text")

还能这样使用:
[link text][]
[link text]: http://www.reddit.com

自动链接
<http://ibruce.info>
Email 邮件:
<example@example.com>

我的主页


![GitHub Mark](http://github.global.ssl.fastly.net/images/modules/logos_page/GitHub-Mark.png "GitHub Mark")

GitHub MarkGitHub Mark

语法高亮:

```html
    <div>Syntax Highlighting</div>
<div>Syntax Highlighting</div>

    body{font-size:12px}
body{font-size:12px}

    var s = "JavaScript syntax highlighting";
    alert(s);
var s = "JavaScript syntax highlighting";
alert(s);

    <?php
      echo "hello, world!";
    ?>
<?php
  echo "hello, world!";
?>

    s = "Python syntax highlighting"
    print s
s = "Python syntax highlighting"
print s

***
* 转义字符
Markdown中的转义字符为\,转义的有:

\ 反斜杠
` 反引号
* 星号
_ 下划线
{} 大括号
[] 中括号
() 小括号
# 井号
+ 加号
- 减号
. 英文句号
! 感叹号


* 表格
表格是我觉得 Markdown 比较累人的地方,例子如下:
Tables Are Cool
col 3 is right-aligned $1600
col 2 is centered $12
zebra stripes are neat $1

>| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
| zebra stripes | are neat      |    $1 |

##参考文献

Markdown官网:http://daringfireball.net/projects/markdown/
参考资料:http://markdown.tw/

Markdown在线编辑器:
Dillinger:http://dillinger.io/
Markdown Here:http://markdown-here.com/livedemo.html

###相关文章:
http://ibruce.info/2013/11/26/markdown/
http://www.bluesdream.com/blog/markdown-cheatsheet-syntax-manual.html
上一篇 下一篇

猜你喜欢

热点阅读