博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
github中markdown语言的使用规则
阅读量:4325 次
发布时间:2019-06-06

本文共 3315 字,大约阅读时间需要 11 分钟。

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

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

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

 

段落、标题、区块代码

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

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

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

Markdown 语法:

 

A First Level Header====================A Second Level Header---------------------Now is the time for all good men to come tothe aid of their country. This is just aregular paragraph.The quick brown fox jumped over the lazydog's back.### Header 3> This is a blockquote.> > This is the second paragraph in the blockquote.>> ## This is an H2 in a blockquote

 

  输出 HTML 为:

A First Level Header

A Second Level Header

Now is the time for all good men to come tothe aid of their country. This is just aregular paragraph.

The quick brown fox jumped over the lazydog's back.

Header 3

This is a blockquote.

This is the second paragraph in the blockquote.

This is an H2 in a blockquote

  

修辞和强调

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

Markdown 语法:

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

  输出 HTML 为:

Some of these words are emphasized.Some of these words are emphasized also.

Use two asterisks for strong emphasis.Or, if you prefer, use two underscores instead.

  

列表

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

* Candy.* Gum.* Booze.+ Candy.+ Gum.+ Booze.- Candy.- Gum.- Booze.

  都会输出 HTML 为:

  • Candy.
  • Gum.
  • Booze.

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

 

1. Red2. Green3. Blue

  输出 HTML 为:

  1. Red
  2. Green
  3. Blue

  

链接

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

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

This is an [example link](http://example.com/ "With a Title").输出HTML为:

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"输出HTML为:

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

  

代码

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

I strongly recommend against using any `
` tags.I wish SmartyPants used named entities like `—`instead of decimal-encoded entites like `—`.输出HTML为:

I strongly recommend against using any

tags.

I wish SmartyPants used named entities like instead of decimal-encodedentites like .

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

If you want your page to validate under XHTML 1.0 Strict,you've got to put paragraph tags in your blockquotes:

For example.

输出HTML为:

If you want your page to validate under XHTML 1.0 Strict,you've got to put paragraph tags in your blockquotes:

For example.

  

 

转载于:https://www.cnblogs.com/vitruvi/p/4310015.html

你可能感兴趣的文章
iOS开发网络篇—XML数据的解析
查看>>
[BZOJ4303]数列
查看>>
一般处理程序在VS2012中打开问题
查看>>
C语言中的++和--
查看>>
thinkphp3.2.3入口文件详解
查看>>
POJ 1141 Brackets Sequence
查看>>
Ubuntu 18.04 root 使用ssh密钥远程登陆
查看>>
Servlet和JSP的异同。
查看>>
虚拟机centOs Linux与Windows之间的文件传输
查看>>
ethereum(以太坊)(二)--合约中属性和行为的访问权限
查看>>
IOS内存管理
查看>>
middle
查看>>
[Bzoj1009][HNOI2008]GT考试(动态规划)
查看>>
Blob(二进制)、byte[]、long、date之间的类型转换
查看>>
OO第一次总结博客
查看>>
day7
查看>>
iphone移动端踩坑
查看>>
vs无法加载项目
查看>>
Beanutils基本用法
查看>>
玉伯的一道课后题题解(关于 IEEE 754 双精度浮点型精度损失)
查看>>