Markdown basic and extra syntax

MD basic and extra syntax

1 Italics and Bold

This is italicized, and so is this.

This is bold, and so is this.

You can use italics and bold together if you have to.

2 Links

Simple links

There are three ways to write links. Each is easier to read than the last:

Here's an inline link to Google.
Here's a reference-style link to Google.
Here's a very readable link to Yahoo!.

The link definitions can appear anywhere in the document -- before or after the place where you use them. The link definition names (1 and Yahoo!) can be any unique string, and are case-insensitive; [Yahoo!] is the same as [YAHOO!].

Advanced links: Title attributes

You can also add a title attribute to a link, which will show up when the user holds the mouse pointer it. Title attributes are helpful if your link text is not descriptive enough to tell users where they're going. (In reference links, you can use optionally parentheses for the link title instead of quotation marks.)

Here's a poorly-named link.
Never write "[click here][1]".
Trust [me].

Advanced links: Bare URLs

You can write bare URLs by enclosing them in angle brackets:

My web site is at http://www.attacklab.net.

If you use this format for email addresses, Showdown will encode the address to make it harder for spammers to harvest. Try it and look in the HTML Output pane to see the results:

Humans can read this, but most spam harvesting robots can't: me@privacy.net

3 Headers

There are two ways to do headers in Markdown. (In these examples, Header 1 is the biggest, and Header 6 is the smallest.)

You can underline text to make the two top-level headers:

Header 1

Header 2

The number of = or - signs doesn't matter; you can get away with just one. But using enough to underline the text makes your titles look better in plain text.

You can also use hash marks for all six levels of HTML headers:

Header 1

Header 2

Header 3

Header 4

Header 5
Header 6

The closing # characters are optional.

4 Horizontal Rules

You can insert a horizontal rule by putting three or more hyphens, asterisks, or underscores on a line by themselves:




You can also use spaces between the characters:


All of these examples produce the same output.

5 Lists

Simple lists

A bulleted list:

  • You can use a minus sign for a bullet
  • Or plus sign
  • Or an asterisk

A numbered list:

  1. Numbered lists are easy
  2. Markdown keeps track of the numbers for you
  3. So this will be item 3.

A double-spaced list:

  • This list gets wrapped in <p> tags

  • So there will be extra space between items

Advanced lists: Nesting

You can put other Markdown blocks in a list; just indent four spaces for each nesting level. So:

  1. Lists in a list item:

    • Indented four spaces.
      • indented eight spaces.
    • Four spaces again.
  2. Multiple paragraphs in a list items:

    It's best to indent the paragraphs four spaces
    You can get away with three, but it can get
    confusing when you nest other things.
    Stick to four.

    We indented the first line an extra space to align
    it with these paragraphs. In real use, we might do
    that to the entire list so that all items line up.

    This paragraph is still part of the list item, but it looks messy to humans. So it's a good idea to wrap your nested paragraphs manually, as we did with the first two.

  3. Blockquotes in a list item:

    Skip a line and
    indent the >'s four spaces.

  4. Preformatted text in a list item:

     Skip a line and indent eight spaces.
     That's four spaces for the list
     and four to trigger the code block.
    

6 Blockquotes

Simple blockquotes

Blockquotes are indented:

The syntax is based on the way email programs
usually do quotations. You don't need to hard-wrap
the paragraphs in your blockquotes, but it looks much nicer if you do. Depends how lazy you feel.

Advanced blockquotes: Nesting

You can put other Markdown blocks in a blockquote; just add a > followed by a space:

Parragraph breaks in a blockquote:

The > on the blank lines is optional.
Include it or don't; Markdown doesn't care.

But your plain text looks better to
humans if you include the extra >
between paragraphs.

Blockquotes within a blockquote:

A standard blockquote is indented

A nested blockquote is indented more

You can nest to any depth.

Lists in a blockquote:

  • A list in a blockquote
  • With a > and space in front of it
    • A sublist

Preformatted text in a blockquote:

Indent five spaces total.  The first
one is part of the blockquote designator.

7 Images

Images are exactly like links, but they have an exclamation point in front of them:

![Valid XHTML] (http://w3.org/Icons/valid-xhtml10).

The word in square brackets is the alt text, which gets displayed if the browser can't show the image. Be sure to include meaningful alt text for blind users' screen-reader software.

Just like links, images work with reference syntax and titles:

This page is
valid XHTML
valid XHTML

.

Note:

Markdown does not currently support the shortest reference syntax for images:

Here's a broken
checkmark
checkmark

.

But you can use a slightly more verbose version of implicit reference names:

This
checkmark
checkmark

works.

The reference name (valid icon) is also used as the alt text.

8 Inline HTML

If you need to do something that Markdown can't handle, you can always just use HTML:

Strikethrough humor is <strike>funny</strike>.

Markdown is smart enough not to mangle your span-level HTML:

<u>Markdown works fine in here.</u>

Block-level HTML elments have a few restrictions:

  1. They must be separated from surrounding text by blank
    lines.
  2. The begin and end tags of the outermost block element
    must not be indented.
  3. You can't use Markdown within HTML blocks.

So:
<div style="background-color: lightgray">
You can <em>not</em> use Markdown in here.
</div>

9 Preformatted Text

You can include preformatted text in a Markdown document.

To make a code block, indent four spaces:

printf("goodbye world!");  /* his suicide note
                              was in C */

The text will be wrapped in <pre> and <code> tags, and the browser will display it in a monospaced typeface. The first four spaces will be stripped off, but all other whitespace will be preserved.

You cannot use Markdown or HTML within a code block, which makes them a convenient way to show samples of Markdown or HTML syntax:

<blink>
   You would hate this if it weren't
   wrapped in a code block.
</blink>

10 Code Spans

You can make inline <code> tags by using code spans. Use backticks to make a code span:

Press the <Tab> key, then type a $.

(The backtick key is in the upper left corner of most keyboards.)

Like code blocks, code spans will be displayed in a monospaced typeface. Markdown and HTML will not work within them:

Markdown italicizes things like this: I *love* it.

Don't use the <font> tag; use CSS instead.


  1. http://www.w3.org/QA/Tips/noClickHere
    (Advice against the phrase "click here")
    [me]: http://www.attacklab.net/ "Attacklab" ?

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 229,908評(píng)論 6 541
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 99,324評(píng)論 3 429
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人,你說(shuō)我怎么就攤上這事。” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 178,018評(píng)論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我,道長(zhǎng),這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 63,675評(píng)論 1 317
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 72,417評(píng)論 6 412
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 55,783評(píng)論 1 329
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼。 笑死,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,779評(píng)論 3 446
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 42,960評(píng)論 0 290
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 49,522評(píng)論 1 335
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 41,267評(píng)論 3 358
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 43,471評(píng)論 1 374
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,009評(píng)論 5 363
  • 正文 年R本政府宣布,位于F島的核電站,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 44,698評(píng)論 3 348
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 35,099評(píng)論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 36,386評(píng)論 1 294
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 52,204評(píng)論 3 398
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 48,436評(píng)論 2 378

推薦閱讀更多精彩內(nèi)容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,512評(píng)論 5 6
  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,761評(píng)論 0 23
  • 2017年10月2日 天變涼了 本想著要和她出去玩,可逢年過(guò)節(jié)的,她總得去走個(gè)親戚,這事怕是得不了了之了。...
    恐世間離散之懼閱讀 125評(píng)論 0 0
  • 你可知道睡眠有多重要?我去你妹的,給我做惡夢(mèng),說(shuō)好了我?guī)湍惆咽虑樽隽耍蛣e折騰。我大把事情要處理。你要給她的我都會(huì)...
    阿貍世界閱讀 74評(píng)論 0 0
  • 打卡97天,將近100天了,時(shí)間過(guò)的好快,想當(dāng)初小芳姐姐拉我進(jìn)來(lái)的時(shí)候,還在緊張著自己做不好,無(wú)法堅(jiān)持下來(lái),...
    阮琳倩閱讀 246評(píng)論 0 0