Markdown 语法介绍

2018-07-25  本文已影响0人  小超2020

Markdown 是一种轻量级标记语言,让写作者专注于写作而不用关注样式。Coding 的许多版块均采用了 Markdown 语法,比如冒泡、讨论、Pull Request 等。

【转】原文链接

锚点

访问链接;

引用

Markdown 标记区块引用和 email 中用 『>』的引用方式类似,只需要在整个段落的第一行最前面加上 『>』 :

Coding.net 为软件开发者提供基于云计算技术的软件开发平台,包括项目管理,代码托管,运行空间和质量控制等等。

列表

列表项目标记通常放在最左边,项目标记后面要接一个字符的空格。
无序列表:使用星号、加号或是减号作为列表标记

  1. Red
  2. Green
  3. Blue
    如果要在列表项目内放进引用,那『>』就需要缩进:

代码

只要把你的代码块包裹在 “` 之间,你就不需要通过无休止的缩进来标记代码块了。 在围栏式代码块中,你可以指定一个可选的语言标识符,然后我们就可以为它启用语法着色了。 举个例子,这样可以为一段 Ruby 代码着色:

#rubu
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
// java
public static void main(String [] args){
  System.println("hello markdown!");
}

强调

在Markdown中,可以使用 * 和 _ 来表示斜体和加粗。
斜体:

Coding,让开发更简单
Coding,让开发更简单
加粗:

Coding,让开发更简单
Coding,让开发更简单

自动链接

方括号显示说明,圆括号内显示网址, Markdown 会自动把它转成链接,例如:
GitHub
超强大的云开发平台Coding

表格

在 Markdown 中,可以制作表格,例如:

First Header Second Header Third Header
Content Cell Content Cell Content Cell
Content Cell Content Cell Content Cell

或者也可以让表格两边内容对齐,中间内容居中,例如:

First Header Second Header Third Header
Left Center Right
Left Center Right

分割线

在 Markdown 中,可以使用 3 个以上『-』符号制作分割线,例如:

这是分隔线上部分内容

这是分隔线上部分内容

图片

Markdown 使用了类似链接的语法来插入图片, 包含两种形式: 内联 和 引用.

内联图片语法如下:

[图片上传失败...(image-c19beb-1532498510684)]

[图片上传失败...(image-4b1a27-1532498510684)]
也就是:

一个惊叹号『!』
接着一个方括号,里面是图片的替代文字
接着一个普通括号,里面是图片的网址,最后还可以用引号包住并加上 选择性的『title’』文字。
引用图片语法如下:

Alt textAlt text

『id』 是图片引用的名称. 图片引用使用链接定义的相同语法:

以下简书暂不支持

流程图

Markdown 编辑器已支持绘制流程图、时序图和甘特图。通过 mermaid 实现图形的插入,点击查看 更多语法详情

<pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, monaco, monospace; font-size: 15px; background: rgb(245, 248, 250); display: block; padding: 15px 20px; line-height: 25px; color: rgb(75, 77, 77); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">```graph
graph TD;
A-->B;
A-->C;
B-->D;
C-->E;
E-->F;
D-->F;
F-->G;


### 时序图 

```graph
sequenceDiagram
    participant Alice
    participant Bob
    Alice->John: Hello John, how are you?
    loop Healthcheck
        John->John: Fight against hypochondria
    end
    Note right of John: Rational thoughts 
prevail...
    John-->Alice: Great!
    John->Bob: How about you?
    Bob-->John: Jolly good!

甘特图

gantt
        dateFormat  YYYY-MM-DD
        title Adding GANTT diagram functionality to mermaid
        section A section
        Completed task            :done,    des1, 2014-01-06,2014-01-08
        Active task               :active,  des2, 2014-01-09, 3d
        Future task               :         des3, after des2, 5d
        Future task2               :         des4, after des3, 5d
        section Critical tasks
        Completed task in the critical line :crit, done, 2014-01-06,24h
        Implement parser and jison          :crit, done, after des1, 2d
        Create tests for parser             :crit, active, 3d
        Future task in critical line        :crit, 5d
        Create tests for renderer           :2d
        Add to mermaid                      :1d
上一篇 下一篇

猜你喜欢

热点阅读