markdown语法学习

来源:互联网 发布:手机信号防干扰软件 编辑:程序博客网 时间:2024/06/01 08:53

MarkDown Learning

  • MarkDown Learning
    • Instruction
    • Paragraph
    • Title
    • Blockquotes
    • List
    • CodeBlock
    • Links
    • Strong
    • Images
    • Tables
    • Help


Instruction

MarkDown是纯文本格式的语法,支持转换为html,可以帮助整理知识、学习笔记

Paragraph

MarkDown的段落是由若干行文本组成,前后由空行隔开;普通段落不该用空格或制表符缩进

Title

MarkDown支持两种标题样式:Setext和atx
Setext风格的标题用符号=(first level)和-(second level)标注在文字下方

This is an h1.=============This is an h2.-------------

atx风格的标题是将若干个#符号放在开始,例如

# This is an h1. ### This is an h2. ######## This is an h6. ###

结尾处的#符号是可选的,而且数量与开始端不要求保持相同

Blockquotes

MarkDown中的区块引用用类似email中的>的引用方式,即现在区块引用内部断好行,再在每行开始添加>

> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.> > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse> id sem consectetuer libero luctus adipiscing.

MarkDown也支持仅在段落开始添加>,在区块引用内部,可以使用MarkDown的语法

List

MarkDown支持有序和无序列表
无序列表使用* + -符号作为列标记

* Red* Blue* Green

有序列表使用数字和符号.

1. Bird2. Fish3. Chicken

其实列表数字的正确与否并不影响html输出
列表项目标记通常放在最左边,标记后要接空格或制表符

CodeBlock

要标记段落为代码块,仅需缩进单个制表符

This is a normal paragraph.    This is a code block.

也可以利用```来标记代码块, 添加代码高亮

```jsvar b= {};```

假如要在行内标记代码(内联代码),可使用符号反引号

This is a `inline code block`

MarkDown支持两种风格的链接:内联和引用
两种样式的链接文本都是由方括号限定
要创建内联的链接,在方括号后紧接由常规括号包括的URL,描述URL的文本可选

[I'm an inline-style link](https://www.google.com)[I'm an inline-style link with title](https://www.google.com "Google's Homepage")[I'm a reference-style link][Arbitrary case-insensitive reference text][I'm a relative reference to a repository file](../blob/master/LICENSE)

在引用链接中,需要额外的方括号,内部填写引用的链接标签

This is [an example][id] reference-style link.

在文档的其他地方定义该链接标签,这样支持链接的复用

[id]: http://example.com/  "Optional Title Here"

Strong

MarkDown使用*_作为标记强调字符的符号,被 *_包围的字符被转换为<em>标记,使用两个的话,则转换为<strong>

*single asterisks*_single underscores_**double asterisks**__double underscores__

假如*_字符两边都有空白的话,会被当做普通字符

Images

MarkDown中的图片与链接非常相似,区别主要体现在下面两点

  • 首个方括号必须把符号!作为前缀
  • 方括号内部的文本是可选的,描述文本在图片为正确加载是显示

.

# Inline![Alternative text](/path/to/img.jpg "Optional title")# Reference![Alternative text][id][id]: url/to/image  "Optional title" 

Tables

MarkDown支持表格

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

符号:表示文本的对齐方式

Help

0 0
原创粉丝点击