Markdown Cheatsheet
注:原文摘自网上
Installation
This post uses hexo-renderer-markdown-it
plugin as markdown processor, so please install it to achieve the effect.
1 | npm un hexo-renderer-marked --save |
Configuration
Add following to _config.yml
of your site.
1 | markdown: |
Usage
Headings
1 | # h1 Heading 8-) |
h1 Heading 8-)
h2 Heading
h3 Heading
h4 Heading
h5 Heading
h6 Heading
Horizontal Rules
1 | ___ |
Typographic replacements
1 | (c) (C) (r) (R) (tm) (TM) (p) (P) +- |
(c) (C) (r) (R) (tm) (TM) (p) (P) +-
test.. test… test….. test?….. test!….
!!!!!! ???? ,, – —
“Smartypants, double quotes” and ‘single quotes’
Emphasis
1 | **This is bold text** |
This is bold text
This is bold text
This is italic text
This is italic text
Strikethrough
Blockquotes
1 | > Blockquotes can also be nested... |
Blockquotes can also be nested…
…by using additional greater-than signs right next to each other…
…or with spaces between arrows.
Lists
Unordered
1 | + Create a list by starting a line with `+`, `-`, or `*` |
- Create a list by starting a line with
+
,-
, or*
- Sub-lists are made by indenting 2 spaces:
- Marker character change forces new list start:
- Ac tristique libero volutpat at
- Facilisis in pretium nisl aliquet
- Nulla volutpat aliquam velit
- Marker character change forces new list start:
- Very easy!
Ordered
1 | 1. Lorem ipsum dolor sit amet |
- Lorem ipsum dolor sit amet
- Indented list
- Another level
- Indent
- Indented list
- Consectetur adipiscing elit
- Integer molestie lorem at massa
1 | 1. You can use sequential numbers... |
- You can use sequential numbers…
- …or keep all the numbers as
1.
Start numbering with offset:
1 | 57. foo |
- foo
- bar
Code
1 | Inline `code` |
Inline code
Indented code
1 | // Some comments |
// Some comments
line 1 of code
line 2 of code
line 3 of code
Block code “fences”
1 | ``` |
1 | Sample text here... |
Syntax highlighting1
2
3
4
5
6
7``` js sample.js
var foo = function (bar) {
return bar++;
};
console.log(foo(5));
```
1 | var foo = function (bar) { |
Tables
1 | | Option | Description |Description | Description | Description | Description | |
Option | Description | Description | Description | Description | Description |
---|---|---|---|---|---|
data | path to data files to supply the data that will be passed into templates. | ||||
engine | engine to be used for processing templates. Handlebars is the default. | ||||
ext | extension to be used for dest files. |
Right aligned columns
1 | | Option | Description | |
Option | Description |
---|---|
data | path to data files to supply the data that will be passed into templates. |
engine | engine to be used for processing templates. Handlebars is the default. |
ext | extension to be used for dest files. |
Links
1 | [link text](http://dev.nodeca.com) |
1 | [link with title](http://nodeca.github.io/pica/demo/ "title text!") |
1 | Autoconverted link https://github.com/nodeca/pica (enabled linkify) |
Autoconverted link https://github.com/nodeca/pica (enabled linkify)
Images
1 | ![Minion](https://octodex.github.com/images/minion.png) |
Like links, Images also have a footnote style syntax
1 | ![Alt text][id] |
With a reference later in the document defining the URL location:
Plugins
The killer feature of markdown-it
is very effective support of
syntax plugins. The sample configuration snippet
Emojies
1 | Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum: |
Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum:
Shortcuts (emoticons): :-) :-( 8-) ;)
Subscript / Superscript
1 | Superscript: 19^th^ |
Superscript: 19^th^
Subscript: H~2~O
\
1 | ++Inserted text++ |
++Inserted text++
\
1 | ==Marked text== |
==Marked text==
Footnotes
1 | Footnote 1 link[^first]. |
Footnote 1 link[^first].
Footnote 2 link[^second].
Inline footnote^[Text of inline footnote] definition.
Duplicated footnote reference[^second].
[^first]: Footnote can have markup
and multiple paragraphs.
[^second]: Footnote text.
Definition lists
1 | Term 1 |
Term 1
: Definition 1
with lazy continuation.
1 | Term 2 with *inline markup* |
Term 2 with inline markup
: Definition 2
{ some code, part of Definition 2 }
Third paragraph of definition 2.
Compact style:
1 | Term 1 |
Term 1
~ Definition 1
Term 2
~ Definition 2a
~ Definition 2b
Abbreviations
1 | This is HTML abbreviation example. |
This is HTML abbreviation example.
It converts “HTML”, but keep intact partial entries like “xxxHTMLyyy” and so on.
*[HTML]: Hyper Text Markup Language
Custom containers
::: warning
here be dragons
:::
Hexo Built-in Tags
Blockquote with author
1 | {% blockquote David Levithan, Wide Awake %} |
Do not just seek happiness for yourself. Seek happiness for all. Through kindness. Through mercy.
Blockquote for twitter
1 | {% blockquote @DevDocs https://twitter.com/devdocs/status/356095192085962752 %} |
NEW: DevDocs now comes with syntax highlighting. http://devdocs.io
Blockquote for weblink
1 | {% blockquote Seth Godin http://sethgodin.typepad.com/seths_blog/2009/07/welcome-to-island-marketing.html Welcome to Island Marketing %} |
Every interaction is both precious and an opportunity to delight.
Pull Quotes
1 | {% pullquote %} |
content
jsFiddle
1 | {% jsfiddle o2gxgz9r default light %} |
Gist
1 | {% gist b6365e79be6052e7531e7ba6ea8caf23 'Sample gist' %} |
iFrame
1 | {% iframe https://leewp14.github.io %} |
Link to open in new tab
1 | {% link Google https://www.google.com default Google %} |
Youtube
1 | {% youtube sCI4bUHoTVY %} |