markdown升级攻略2

前言

本文根据markdown官方文档总结出小白使用Markdown的无脑 正确姿势。

标题#

标题前添加“#”(数量1-6)

# This is an H1

## This is an H2

另一种写法:在文本下一行添加 “ = ”和“ - ”组成的 “分割线 ”(====================(用于第一级标头)或者---------------------(用于第二级标头))。例如:

A First Level Header
====================

A Second Level Header
--------------------

两种写法输出效果是一样的:

A First Level Header

A Second Level Header

A Second Level Header

引用>

在引用的文字前添加“>”。

> This is a blockquote.
> This is the second paragraph in the blockquote.
> ## This is an H2 in a blockquote

输出:

This is a blockquote.

This is the second paragraph in the blockquote.

This is an H2 in a blockquote

>>嵌套引用 添加标题列表代码块直接添加相关代码:

> ## This is a header.
> 
>> 1.   This is the first list item.
>> 2.   This is the second list item.
> 
> Here's some example code:
> 
>     return shell_exec("echo $input | $markdown_script");

输出:

This is a header.
  1. This is the first list item.
  2. This is the second list item.

Here’s some example code:

return shell_exec(“echo $input | $markdown_script”);

清单

无序 (* + -)

* ,+ ,- 有一样的效果

*   Candy.
*   Gum.
*   Booze.

这个:

+   Candy.
+   Gum.
+   Booze.

还有这个:

-   Candy.
-   Gum.
-   Booze.

全部产生相同的输出:

  • Candy.
  • Gum.
  • Booze.

有序(1.2.3.)

1.  Bird
2.  McHale
3.  Parish

输出:

  1. Bird
  2. McHale
  3. Parish

高级(与html的关系)
如果列表项用空白行分隔,则Markdown会包装HTML输出中<p>标记中的项目:

*   Bird
*   Magic

输出:

  • Bird
  • Magic

  • 代码

    代码块 ```

    预格式化的代码块用于编写有关编程或标记源代码。这些行而不是形成普通的段落代码块中的一个按字面意义解释。Markdown包装了一个代码块在<pre><code>标签中。

    要在Markdown中生成代码块,只需缩进代码行的每一行至少间隔4个空格或1个制表符。例如,给定此输入:

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

    输出:

    This is a normal paragraph:

        This is a code block.
    

    扩展:HTML中

    <p>This is a normal paragraph:</p>
    
    <pre><code>This is a code block.
    </code></pre>
    

    从每个缩进一级缩进-4个空格或1个制表符代码块的行。

    Here is an example of AppleScript:
    
        tell application "Foo"
            beep
        end tell
    

    输出:

    Here is an example of AppleScript:

    tell application "Foo"
           = beep
    end tell
    

    代码块将继续直到到达未缩进的行(或文章结尾)。

    在代码块内,与号()和尖括号(<>)会自动转换为HTML实体。这使得它非常使用Markdown轻松包含示例HTML源代码-只需粘贴并缩进它,Markdown将处理编码的麻烦和号和尖括号。

        <div class="footer">
            &copy; 2004 Foo Corporation
        </div>
    

    输出:


    扩展:HTML中

    <pre><code>&lt;div class="footer"&gt;
    &amp;copy; 2004 Foo Corporation
    &lt;/div&gt;
    </code></pre>
    

    代码 ``

    要指示代码范围,请使用反引号将其引起来(```’’)。与预先格式化的代码块不同,代码跨度指示正常段落。例如:

    Use the `printf()` function.
    

    输出

    Use the printf() function.

    要在代码范围内包含文字反引号字符,可以使用多个反引号作为开始和结束定界符:

    ``There is a literal backtick (`) here.``
    

    输出

    There is a literal backtick (`) here.


    代码范围周围的反引号分隔符可能包含空格-打开后一个,关闭前一个。这可以让您放置在代码范围的开头或结尾处的文字反引号字符:

    A single backtick in a code span: `` ` ``
    
    A backtick-delimited string in a code span: `` `foo` ``
    

    输出

    A single backtick in a code span: `

    A backtick-delimited string in a code span: `foo`


    使用代码跨度时,“&”号和尖括号被编码为HTML实体自动生成,因此很容易包含示例HTML标签。Markdown会变成这样:

    Please don't use any `<blink>` tags.
    

    输出

    Please don't use any <blink> tags.

    您可以这样写:

    `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
    

    输出

    &#8212; is the decimal-encoded equivalent of &mdash;.

    水平线 ***

    <hr />

    * * *
    
    ***
    
    *****
    
    - - -
    
    ---------------------------------------
    

    超链接

    链接

    Markdown支持两种链接样式:inlinereference。超链接在[方括号]中,地址在(小括号)内。请例如:

    This is [an example](http://example.com/ "Title") inline link.
    
    [This link](http://example.net/) has no title attribute.
    

    输出

    This is an example inline link.

    This link has no title attribute.


    在HTML中的代码:

    <p>This is <a href="http://example.com/" title="Title">
    an example</a> inline link.</p>
    
    <p><a href="http://example.net/">This link</a> has no
    title attribute.</p>
    

    如果要引用同一服务器上的本地资源,则可以使用相对路径:

    See my [About](/about/) page for details.  
    

    输出

    See my About page for details.


    以下三个链接定义是等效的:

    [foo]: http://example.com/  "Optional Title Here"
    
    [foo]: http://example.com/  'Optional Title Here'
    
    [foo]: http://example.com/  (Optional Title Here)
    

    Note: 链接URL可以可选地用尖括号括起来可以防止其他符号的影响:

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

    强调** **

    Markdown将星号()和下划线(__)视为重点。用或_换行的文本将用换行HTML<em>标签;双*_将被HTML换行<strong>标签。

    HTML:

    <em>single asterisks</em>
    
    <em>single underscores</em>
    
    <strong>double asterisks</strong>
    
    <strong>double underscores</strong>
    

    markdown中:

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

    输出:

    single asterisks

    single underscores

    double asterisks
    double underscores


    您可以使用任何喜欢的样式。唯一的限制是必须使用相同的字符来打开和关闭重点跨度。强调可以用在单词的中间:

    un*frigging*believable
    

    但是,如果您在*_周围加上空格,则将其视为文字星号或下划线。在其位置产生文字星号或下划线否则将用作强调定界符,您可以反斜杠逃脱它:

    \*this text is surrounded by literal asterisks\*
    

    图片

    类似链接,允许两种样式:* inline reference *。

    ![Alt text](/path/to/img.jpg)
    
    ![Alt text](/path/to/img.jpg "Optional title")
    

    引用样式的图像语法如下所示:

    ![Alt text][id]
    

    其中“ id”是定义的图像引用的名称。图片参考使用与链接引用相同的语法定义:

    [id]: url/to/image  "Optional title attribute"
    

    如果要更改图片大小,需要使用常规HTML<img>标签。

    其他

    自动链接<>

    用尖括号将URL或电子邮件地址括起来。

    <http://example.com/>
    

    http://example.com/

    如果是邮箱地址,Markdown会执行一些随机的十进制和十六进制实体编码,以掩盖你真实邮箱地址,防止地址收集机器人收集你的信息。
    在Markdown中输入:

    <address@example.com>
    

    输出:

    address@example.com

    而它的HTML是这样的:

    <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
    &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
    &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
    &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
    

    自定义格式

    markdown并没有直接的更改功能,需要结合HTML进行更改
    表格与引用的背景色更改:

    <table><td bgcolor=yellow>
    背景色
    </td></table>
    

    字体颜色大小

    <font color=颜色 size=数字>

    图片大小

    <img src="图片名称" width="50%" height="50%">

    图片居中

    <div align=right><img src="图片名称" width="50%" height="50%"></div>

    直接使用符号 \

    \可以跳过markdown语法直接使用符号:

    符号英文中文
    \backslash反斜杠
    `backtick反t
    *asterisk星号
    _underscore下划线
    {}curly braces大括号
    []square brackets中括号
    ()parentheses括弧
    #hash mark井号
    +plus sign加号
    -minus sign (hyphen)减号
    .dot
    !exclamation mark感叹号
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值