title: Markdown date: 2014-12-25 00:31:00 categories: - Technology - Github tags: - markdown banner: /hexo-theme-icarus/gallery/markdown.jpg --- A markdown example shows how to write a markdown file. This document integrates core syntax and extensions (GMF). * [Block Elements](#block-elements) * [Paragraphs and Line Breaks](#paragraphs-and-line-breaks) * [Headers](#headers) * [Blockquotes](#blockquotes) * [Lists](#lists) * [Code Blocks](#code-blocks) * [Horizontal Rules](#horizontal-rules) * [Table](#table) * [Span Elements](#span-elements) * [Links](#links) * [Emphasis](#emphasis) * [Code](#code) * [Images](#images) * [Strikethrough](#strikethrough) * [Miscellaneous](#miscellaneous) * [Automatic Links](#automatic-links) * [Backslash Escapes](#backslash-escapes) * [Inline HTML](#inline-html) ## Block Elements ### Paragraphs and Line Breaks #### Paragraphs HTML Tag: `
`
One or more blank lines. (A blank line is a line containing nothing but **spaces** or **tabs** is considered blank.)
Code:
This will be
inline.
This is second paragraph.
Preview:
***
This will be
inline.
This is second paragraph.
***
#### Line Breaks
HTML Tag: `
`
End a line with **two or more spaces**.
Code:
This will be not
inline.
Preview:
***
This will be not
inline.
***
### Headers
Markdown supports two styles of headers, Setext and atx.
#### Setext
HTML Tags: `
` Markdown uses email-style **>** characters for blockquoting. It looks best if you hard wrap the text and put a > before every line. Code: > 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. Preview: *** > 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 allows you to be lazy and only put the > before the first line of a hard-wrapped paragraph. Code: > 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. Preview: *** > 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. *** Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by adding additional levels of >. Code: > This is the first level of quoting. > > > This is nested blockquote. > > Back to the first level. Preview: *** > This is the first level of quoting. > > > This is nested blockquote. > > Back to the first level. *** Blockquotes can contain other Markdown elements, including headers, lists, and code blocks. Code: > ## 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"); Preview: *** > ## 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"); *** ### Lists Markdown supports ordered (numbered) and unordered (bulleted) lists. #### Unordered HTML Tag: `` Unordered lists use **asterisks (*)**, **pluses (+)**, and **hyphens (-)**. Code: * Red * Green * Blue Preview: *** * Red * Green * Blue *** is equivalent to: Code: + Red + Green + Blue and: Code: - Red - Green - Blue #### Ordered HTML Tag: `
` Ordered lists use numbers followed by periods: Code: 1. Bird 2. McHale 3. Parish Preview: *** 1. Bird 2. McHale 3. Parish *** It’s possible to trigger an ordered list by accident, by writing something like this: Code: 1986. What a great season. Preview: *** 1986. What a great season. *** You can **backslash-escape (\\)** the period: Code: 1986\. What a great season. Preview: *** 1986\. What a great season. *** #### Indented ##### Blockquote To put a blockquote within a list item, the blockquote’s > delimiters need to be indented: Code: * A list item with a blockquote: > This is a blockquote > inside a list item. Preview: *** * A list item with a blockquote: > This is a blockquote > inside a list item. *** ##### Code Block To put a code block within a list item, the code block needs to be indented twice — **8 spaces** or **two tabs**: Code: * A list item with a code block:
Preview: *** * A list item with a code block:
*** ##### Nested List Code: * A * A1 * A2 * B * C Preview: *** * A * A1 * A2 * B * C *** ### Code Blocks HTML Tag: `
` Indent every line of the block by at least **4 spaces** or **1 tab**. Code: This is a normal paragraph: This is a code block. Preview: *** This is a normal paragraph: This is a code block. *** A code block continues until it reaches a line that is not indented (or the end of the article). Within a code block, ***ampersands (&)*** and angle **brackets (< and >)** are automatically converted into HTML entities. Code:Preview: *** *** Following sections Fenced Code Blocks and Syntax Highlighting are extensions, you can use the other way to write the code block. #### Fenced Code Blocks Just wrap your code in ```` ``` ```` (as shown below) and you won't need to indent it by four spaces. Code: Here's an example: ``` function test() { console.log("notice the blank line before this function?"); } ``` Preview: *** Here's an example: ``` function test() { console.log("notice the blank line before this function?"); } ``` *** #### Syntax Highlighting In your fenced block, add an optional language identifier and we'll run it through syntax highlighting ([Support Languages](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml)). Code: ```ruby require 'redcarpet' markdown = Redcarpet.new("Hello World!") puts markdown.to_html ``` Preview: *** ```ruby require 'redcarpet' markdown = Redcarpet.new("Hello World!") puts markdown.to_html ``` *** ### Horizontal Rules HTML Tag: `
` Places **three or more hyphens (-), asterisks (*), or underscores (_)** on a line by themselves. You may use spaces between the hyphens or asterisks. Code: * * * *** ***** - - - --------------------------------------- ___ Preview: *** * * * *** ***** - - - --------------------------------------- ___ *** ### Table HTML Tag: `