乐趣区

关于markdown:Markdown语法详解

简介

Markdown 有两层意思:一是轻量级、纯文本语法格局的标记语言;二是编辑并解析 markdown 语法,展现最终文字排版成果的客户端。markdown 使得文字排版标准化,能够轻松转换成 HTML 或其余格局。让你专一于文字内容,而无需浪费时间在文字排版上。


题目

语法:#

  • markdown 写法:

    # Heading level 1
    ## Heading level 2
    ### Heading level 3
    #### Heading level 4
    ##### Heading level 5
    ###### Heading level 6

段落

语法:空行宰割,造成段落

  • markdown 写法:

    段落 1。段落 2。
  • 实际效果:

    段落 1。

段落 2。


换行

语法:失常段落换行用 2 空格 + 回车;表格中换行用<br>

  • markdown 写法:

    This is the first line.  
    And this is the second line.
    
    This is the first line.<br>
    And this is the second line.
  • 实际效果:
    This is the first line.
    And this is the second line.

    This is the first line.
    And this is the second line.


斜体

语法:用 * 或者 _ 蕴含斜体内容

  • markdown 写法:

    Italicized text is the *cat's meow*.  
    Italicized text is the _cat's meow_.
  • 实际效果:

    Italicized text is the cat’s meow.

    Italicized text is the _cat’s meow_.


粗体

** 或者 __ 蕴含加粗内容;

  • markdown 写法:

    I just love **bold text**.
    I just love __bold text__.
  • 实际效果:

    I just love bold text.

    I just love __bold text__.


粗体 + 斜体

***___蕴含内容

  • markdown 写法:

    This text is ***really important***.
    This text is ___really important___.
    This text is __*really important*__.
    This text is **_really important_**.
    • 实际效果:
      This text is really important.
      This text is ___really important___.
      This text is __really important__.
      This text is really important.

段落援用

  1. 段落开始处加上>

    • Markdown 写法
      > Dorothy followed her through many of the beautiful rooms in her castle.
    • 实际效果:

      Dorothy followed her through many of the beautiful rooms in her castle.

  2. 多个段落援用

    • Markdown 写法

      > Dorothy followed her through many of the beautiful rooms in her castle.  
      >
      > The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
    • 实际效果:

      Dorothy followed her through many of the beautiful rooms in her castle.

      The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.

  3. 段落嵌套援用

    • Markdown 写法

      > Dorothy followed her through many of the beautiful rooms in her castle.
      >
      >> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
    • 实际效果:

      Dorothy followed her through many of the beautiful rooms in her castle.

      The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.

  4. 援用与其余元素配合应用

    • Markdown 写法

      > **The quarterly results look great!**
      >
      > - Revenue was off the chart.
      > - Profits were higher than ever.
      >
      >  *Everything* is going according to **plan**.
    • 实际效果:

      The quarterly results look great!

      • Revenue was off the chart.
      • Profits were higher than ever.

        Everything is going according to plan.


列表

  1. 有序列表

    • Markdown 写法

      1. First item
      2. Second item
      3. Third item
      4. Fourth item
    • 实际效果:(因为缩进上面本应该显示 1,2,3 这样的序列)

      1. First item
      2. Second item
      3. Third item
      4. Fourth item
  2. 无序列表 (-+* 用这三种符号实现)

    • Markdown 写法 (上面只用- 阐明)

      - First item
      - Second item
      - Third item
          - Indented item
          - Indented item
      - Fourth item
    • 实际效果:

      • First item
      • Second item
      • Third item

        • Indented item
        • Indented item
      • Fourth item
  3. 列表中插入段落

    • Markdown 写法

      *   This is the first list item.
      *   Here's the second list item.
      
          I need to add another paragraph below the second list item.
      
      *   And here's the third list item.
    • 实际效果:

      • This is the first list item.
      • Here’s the second list item.

        I need to add another paragraph below the second list item.
        
      • And here’s the third list item.
  4. 列表中插入块援用

    • Markdown 写法

      *   This is the first list item.
      *   Here's the second list item.
      
          > I need to add another paragraph below the second list item.
      
      *   And here's the third list item.
    • 实际效果:

      • This is the first list item.
      • Here’s the second list item.

        I need to add another paragraph below the second list item.

      • And here’s the third list item.

代码块

  1. 用 ` 包含一个词或短语

    • Markdown 写法

      At the command prompt, type `nano`.
    • 实际效果:

      At the command prompt, type nano.

  2. ` 蕴含代码块

    • Markdown 写法

      <head>
          <title>Test</title>
      </head>
    • 实际效果:

      <head>
        <title>Test</title>
      </head>
      

分割线

语法:***---___

  • Markdown 写法

    ***
    ---
    ___
  • 实际效果:

    _


链接

  1. 格局:[链接名](URL)

    • Markdown 写法

      My favorite search engine is [Duck Duck Go](https://duckduckgo.com).
    • 实际效果:

      My favorite search engine is Duck Duck Go.

  2. 格局:[链接名](URL "Title") 减少链接 Title(鼠标悬浮时显示)

    • Markdown 写法

      My favorite search engine is [Duck Duck Go](https://duckduckgo.com "The best search engine for privacy").
    • 实际效果:

      My favorite search engine is Duck Duck Go.

  3. 链接配合其余元素应用

    • Markdown 写法

      I love supporting **[EFF](https://eff.org)**.
      This is the *[Markdown Guide](https://www.markdownguide.org)*.
    • 实际效果:

      I love supporting EFF.

      This is the Markdown Guide.

  4. 链接嵌套

    • Markdown 写法

      [![百度首页](www.baidu.com/img/baidu_jgylogo3.gif "百度首页")](www.baidu.com)
    • 实际效果:

  5. 原文加链接优化

    • Markdown 写法

      In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole, filled with the ends
      of worms and an oozy smell, nor yet a dry, bare, sandy hole with nothing in it to sit down on or to
      eat: it was a [hobbit-hole](https://en.wikipedia.org/wiki/Hobbit#Lifestyle "Hobbit lifestyles"), and that means comfort.
      
      下面的写法和上面的写法,展现成果是一样的,然而下面把链接插入在原文中很不好浏览,能够用上面形式,不便批改浏览:In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole, filled with the ends
      of worms and an oozy smell, nor yet a dry, bare, sandy hole with nothing in it to sit down on or to
      eat: it was a [hobbit-hole][1], and that means comfort.  
      
      [1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> "Hobbit lifestyles"
    • 实际效果:

      In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole, filled with the ends
      of worms and an oozy smell, nor yet a dry, bare, sandy hole with nothing in it to sit down on or to
      eat: it was a hobbit-hole, and that means comfort.

    [1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> "Hobbit lifestyles"

URL 变链接

语法:<URL>

  • Markdown 写法

    <https://www.markdownguide.org>
    <fake@example.com>
  • 实际效果:

    https://www.markdownguide.org

    mailto:fake@example.com


图片

语法:![图片名](URL)

  • Markdown 写法

    1.  Open the file containing the Linux mascot.
    2.  Marvel at its beauty.
    
    ![Tux, the Linux mascot](http://www.baidu.com/img/baidu_jgylogo3.gif)
    
    3.  Close the file.
  • 实际效果:

    1. Open the file containing the Linux mascot.
    2. Marvel at its beauty.

    1. Close the file.

特殊字符反援用

语法:\用反斜杠能够反援用上面特殊字符

  • Markdown 写法

    * Without the backslash, this would be a bullet in an unordered list.
    \* Without the backslash, this would be a bullet in an unordered list.
  • 实际效果:

    • Without the backslash, this would be a bullet in an unordered list.

      * Without the backslash, this would be a bullet in an unordered list.

  • 能够解决的特殊字符

    \`*-{}[]()#+-·! 

兼容 HTML

Markdown 中能够直接插入 HTML,解析库默认是不凋谢的,须要参考对应库文档,markdown-it 设置html: true

1、Markdown 文件里加上 HTML 表格:
  • markdown 写法:

    这是一个一般段落。<table>
    <tr>
        <td>Foo</td>
    </tr>
    </table>
    这是另一个一般段落。
  • 实际效果

    这是一个一般段落。

    Foo

    这是另一个一般段落。


2、Markdown 嵌入视频
  • markdown 写法:

    1. 插入视频
    <video src="视频链接" width="320" height="180" controls="controls"></video> 
  • 实际效果:

    <video src=” 视频连贯 ” width=”320″ height=”180″ controls=”controls”></video>


表格

语法:应用 | 来分隔不同的单元格,应用 - 来分隔表头和其余行。

  • markdown 写法:

    | 左对齐 | 右对齐 | 居中对齐 |
    | :-----| ----: | :----: |
    | 单元格 | 单元格 | 单元格 |
    | 单元格 | 单元格 | 单元格 |
      
    -: 设置内容和标题栏居右对齐。:- 设置内容和标题栏居左对齐。:-: 设置内容和标题栏居中对齐。
  • 实际效果:

    | 左对齐 | 右对齐 | 居中对齐 |
    | :—–| —-: | :—-: |
    | 单元格 | 单元格 | 单元格 |
    | 单元格 | 单元格 | 单元格 |


其余参考链接

  • Markdown 语法详解!
退出移动版