开始使用github就接触了markdown,确实如它的宗旨所言"易读易写",语法简洁明了,功能比纯文本更强,是一种非常适用于网络的书写语言。并且一大优点是兼容HTML,只要不在markdown涵盖范围内的标签,都可以直接在文档里用HTML书写。

  相比HTML作为一种'发布'的格式,markdown是一种'书写'的格式。

  下面具体介绍一下markdown的各种语法:

段落、标题、区块代码

  一个段落是由一个以上的连接的行句组成,而一个以上的空行则会划分出不同的段落(空行的定义是显示上看起来像是空行,就被视为空行,例如有一行只有空白和 tab,那该行也会被视为空行),一般的段落不需要用空白或换行缩进。

  Markdown 支持两种标题的语法,Setext 和 atx 形式。Setext 形式是用底线的形式,利用 = (最高阶标题)和 - (第二阶标题),Atx 形式在行首插入 1 到 6 个 # ,对应到标题 1 到 6 阶。

  区块引用则使用 email 形式的 '>' 角括号。

Markdown 语法:

  1. A First Level Header
  2. ====================
  3. A Second Level Header
  4. ---------------------
  5.  
  6. Now is the time for all good men to come to
  7. the aid of their country. This is just a
  8. regular paragraph.
  9.  
  10. The quick brown fox jumped over the lazy
  11. dog's back.
  12. ### Header 3
  13.  
  14. > This is a blockquote.
  15. >
  16. > This is the second paragraph in the blockquote.
  17. >
  18. > ## This is an H2 in a blockquote

  输出 HTML 为:

  1. <h1>A First Level Header</h1>
  2. <h2>A Second Level Header</h2>
  3. <p>Now is the time for all good men to come to
  4. the aid of their country. This is just a
  5. regular paragraph.</p>
  6. <p>The quick brown fox jumped over the lazy
  7. dog's back.</p>
  8. <h3>Header 3</h3>
  9. <blockquote>
  10. <p>This is a blockquote.</p>
  11. <p>This is the second paragraph in the blockquote.</p>
  12. <h2>This is an H2 in a blockquote</h2>
  13. </blockquote>

  

修辞和强调

Markdown 使用星号和底线来标记需要强调的区段。

Markdown 语法:

  1. Some of these words *are emphasized*.
  2. Some of these words _are emphasized also_.
  3. Use two asterisks for **strong emphasis**.
  4. Or, if you prefer, __use two underscores instead__.

  输出 HTML 为:

  1. <p>Some of these words <em>are emphasized</em>.
  2. Some of these words <em>are emphasized also</em>.</p>
  3. <p>Use two asterisks for <strong>strong emphasis</strong>.
  4. Or, if you prefer, <strong>use two underscores instead</strong>.</p>

  

列表

无序列表使用星号、加号和减号来做为列表的项目标记,这些符号是都可以使用的,使用星号:

  1. * Candy.
  2. * Gum.
  3. * Booze.
  4.  
  5. + Candy.
  6. + Gum.
  7. + Booze.
  8.  
  9. - Candy.
  10. - Gum.
  11. - Booze.

  都会输出 HTML 为:

  1. <ul>
  2. <li>Candy.</li>
  3. <li>Gum.</li>
  4. <li>Booze.</li>
  5. </ul>

  有序的列表则是使用一般的数字接着一个英文句点作为项目标记:

  1. 1. Red
  2. 2. Green
  3. 3. Blue

  输出 HTML 为:

  1. <ol>
  2. <li>Red</li>
  3. <li>Green</li>
  4. <li>Blue</li>
  5. </ol>

  

链接

Markdown 支援两种形式的链接语法: 行内 和 参考 两种形式,两种都是使用角括号来把文字转成连结。

行内形式是直接在后面用括号直接接上链接:

  1. This is an [example link](http://example.com/ "With a Title").
  2.  
  3. 输出HTML为:
  4.  
  5. <p>This is an <a href="http://example.com/" title="With a Title">
  6. example link</a>.</p>

  参考形式的链接让你可以为链接定一个名称,之后你可以在文件的其他地方定义该链接的内容:

  1. I get 10 times more traffic from [Google][1] than from
  2. [Yahoo][2] or [MSN][3].
  3.  
  4. [1]: http://google.com/ "Google"
  5. [2]: http://search.yahoo.com/ "Yahoo Search"
  6. [3]: http://search.msn.com/ "MSN Search"
  7.  
  8. 输出HTML为:
  9.  
  10. <p>I get 10 times more traffic from <a href="http://google.com/"
  11. title="Google">Google</a> than from <a href="http://search.yahoo.com/"
  12. title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
  13. title="MSN Search">MSN</a>.</p>

  

图片

图片的语法和链接很像。

行内形式(title 是选择性的):

  1. ![alt text](/path/to/img.jpg "Title")

  参考形式:

  1. ![alt text][id]
  2.  
  3. [id]: /path/to/img.jpg "Title"

  上面两种方法都会输出:

  1. <img src="/path/to/img.jpg" alt="alt text" title="Title" />

  

代码

在一般的段落文字中,你可以使用反引号 ` 来标记代码区段,区段内的 &< 和 > 都会被自动的转换成 HTML 实体,这项特性让你可以很容易的在代码区段内插入 HTML 码:

  1. I strongly recommend against using any `<blink>` tags.
  2.  
  3. I wish SmartyPants used named entities like `—`
  4. instead of decimal-encoded entites like `—`.
  5.  
  6. 输出HTML为:
  7.  
  8. <p>I strongly recommend against using any
  9. <code><blink></code> tags.</p>
  10. <p>I wish SmartyPants used named entities like
  11. <code>&mdash;</code> instead of decimal-encoded
  12. entites like <code>—</code>.</p>

  如果要建立一个已经格式化好的代码区块,只要每行都缩进 4 个空格或是一个 tab 就可以了,而 &< 和 > 也一样会自动转成 HTML 实体。

  1. If you want your page to validate under XHTML 1.0 Strict,
  2. you've got to put paragraph tags in your blockquotes:
  3.  
  4. <blockquote>
  5. <p>For example.</p>
  6. </blockquote>
  7.  
  8. 输出HTML为:
  9.  
  10. <p>If you want your page to validate under XHTML 1.0 Strict,
  11. you've got to put paragraph tags in your blockquotes:</p>
  12. <pre><code><blockquote>
  13. <p>For example.</p>
  14. </blockquote>
  15. </code></pre>

  

github中markdown语言的使用规则的更多相关文章

  1. 原来Github上的README.md文件这么有意思——Markdown语言详解

    转载请注明出处:http://blog.csdn.net/zhaokaiqiang1992 之前一直在使用github,也在上面分享了不少的项目和Demo,每次创建新项目的时候,使用的都是默认的REA ...

  2. 【转录】原来Github上的README.md文件这么有意思——Markdown语言详解

    之前一直在使用github,也在上面分享了不少的项目和Demo,每次创建新项目的时候,使用的都是默认的README.md文件,也不曾对这个文件有过什么了解.但是在看到别人写的项目的README.md里 ...

  3. Github:修改Github仓库中项目语言类型

    前述 有的时候我们把项目上传到github仓库上时语言会显示错误语言 比如一个java项目可能因为有js文件的存在而被识别为js项目 这种时候我们就要手动去修改Github的项目语言类型 解决办法 在 ...

  4. 原来Github上的README.md文件这么有意思——Markdown语言详解(sublime text2 版本)

    一直想学习 Markdown 语言,想起以前读的一篇 赵凯强 的 博客 <原来Github上的README.md文件这么有意思——Markdown语言详解>,该篇博主 使用的是Mac系统, ...

  5. Markdown语言详解

    相信大家在github上面分享了不少的项目和Demo,每次创建新项目的时候,使用的都是默认的README.md文件,也不曾对这个文件有过什么了解.但是在看到别人写的项目的README.md里面竟然有图 ...

  6. Markdown语言.md文件

    转自:http://www.kuqin.com/shuoit/20141125/343459.html 之前一直在使用github,也在上面分享了不少的项目和Demo,每次创建新项目的时候,使用的都是 ...

  7. 关于github中的README.md文件

    0x01 README.md文件是用Markdown语言编写的,md=Markdown; 在线编辑工具: https://stackedit.io/editor# https://maxiang.io ...

  8. Github上Markdown基本语法

    基础写作和语法格式 本篇文章的内容来源于Github的基础写作帮助.如果在观看时有什么问题,可以直接查阅源文件.另外需要说明的是Git对Markdown的支持增加了一些扩展功能,因此在Git上可以渲染 ...

  9. GitHub支持的Markdown语法 GitHub Flavored Markdown

    GitHub支持的Markdown语法,简称GFM.相比标准的Markdown(SM)语法,有少数几个区别,并添加了新的功能. 本位参考 GitHub Flavored Markdown 撰写.有兴趣 ...

随机推荐

  1. python—时间与时间戳之间的转换

    python-时间与时间戳之间的转换 对于时间数据,如2016-05-05 20:28:54,有时需要与时间戳进行相互的运算,此时就需要对两种形式进行转换,在Python中,转换时需要用到time模块 ...

  2. 通过Angular-cli创建新项目

    前提:已经安装Git 方法一:(推荐) 1.在需要创建项目的文件夹中右键打开 Git Bush Here ,在此输入  ng new ‘项目名’  --skip-install   (如下my-app ...

  3. HTML5中类jQuery选择器querySelector和querySelectorAll的使用

    支持的浏览IE8+,Firefox3.5+,Safari3.1+ Chrome和Opera 10+ 1.querySelector()方法接收一个选择符,返回第一个匹配的第一个元素,如果没有返回nul ...

  4. Tarjan求LCA(离线)

    基本思想 把要求的点对保存下来,在dfs时顺带求出来. 方法 将每个已经遍历的点指向它回溯的最高节点(遍历它的子树时指向自己),每遍历到一个点就处理它存在的询问如果另一个点已经遍历,则lca就是另一个 ...

  5. Trees in a Wood UVA - 10214 欧拉函数模板

    太坑惹,,,没用longlong各种WA #include <iostream> #include <string.h> #include <cstdio> #in ...

  6. 2016年省赛 G Triple Nim

    2016年省赛 G Triple Nimnim游戏,要求开始局面为先手必败,也就是异或和为0.如果n为奇数,二进制下最后一位只有两种可能1,1,1和1,0,0,显然异或和为1,所以方案数为0如果n为偶 ...

  7. odoo web controller

    Routing openerp.http.route(route=None, **kw) Decorator marking the decorated method as being a handl ...

  8. [Array]167. Two Sum II - Input array is sorted

    Given an array of integers that is already sorted in ascending order, find two numbers such that the ...

  9. import schedule ImportError: No module named schedule

    安装pip sudo apt-get install python-pip 安装schedule模块 pip install schedule PS: 如果已经安装pip,可能出现以下问题,按照提示重 ...

  10. 解决前端跨域请求(SpringBoot)

    @Configuration public class CorsConfig { private CorsConfiguration buildConfig() { CorsConfiguration ...