Markdown初使用

Sample Markdown Cheat Sheet

This is a sample markdown file to help you write Markdown quickly :)

If you use the fabulous Sublime Text 2/3 editor along with the Markdown Preview plugin, open your ST2 Palette with CMD+P then choose Markdown Preview in browser to see the result in your browser.

Text basics

this is italic and this is bold . another italic and another bold

this is important text. and percentage signs : % and %

This is a paragraph with a footnote (builtin parser only). [1]

Insert [ toc ] without spaces to generate a table of contents (builtin parsers only).

Indentation

Here is some indented text

even more indented

Titles

Big title (h1)

Middle title (h2)

Smaller title (h3)

and so on (hX)

and so on (hX)
and so on (hX)

Example lists (1)

  • bullets can be -, +, or *

  • bullet list 1

  • bullet list 2

    • sub item 1

    • sub item 2

      with indented text inside

  • bullet list 3

  • bullet list 4
  • bullet list 5

Links

This is an example inline link and another one with a title.

Links can also be reference based : reference 1 or reference 2 with title.

References are usually placed at the bottom of the document

Images

A sample image :

revolunet logo
revolunet logo

As links, images can also use references instead of inline links :

revolunet logo
revolunet logo

Code

It's quite easy to show code in markdown files.

Backticks can be used to highlight some words.

Also, any indented block is considered a code block. If enable_highlight is true, syntax highlighting will be included (for the builtin parser - the github parser does this automatically).

<script>
    document.location = 'http://lmgtfy.com/?q=markdown+cheat+sheet';
</script>

Math

When enable_mathjax is true, inline math can be included \(\frac{\pi}{2}\) $\pi$

Alternatively, math can be written on its own line:

$$F(\omega) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} f(t) , e^{ - i \omega t}dt$$

\[\int_0^1 f(t) \mathrm{d}t\]

\[\sum_j \gamma_j^2/d_j\]

GitHub Flavored Markdown

If you use the Github parser, you can use some of Github Flavored Markdown syntax :

  • User/Project@SHA: revolunet/sublimetext-markdown-preview@7da61badeda468b5019869d11000307e07e07401
  • User/Project#Issue: revolunet/sublimetext-markdown-preview#1
  • User : @revolunet

Some Python code :

import random

class CardGame(object):
    """ a sample python class """
    NB_CARDS = 32
    def __init__(self, cards=5):
        self.cards = random.sample(range(self.NB_CARDS), 5)
        print 'ready to play'

Some Javascript code :

var config = {
    duration: 5,
    comment: 'WTF'
}
// callbacks beauty un action
async_call('/path/to/api', function(json) {
    another_call(json, function(result2) {
        another_another_call(result2, function(result3) {
            another_another_another_call(result3, function(result4) {
                alert('And if all went well, i got my result :)');
            });
        });
    });
})

The Github Markdown also brings some nice Emoji support : :+1: :heart: :beer:

Parsers and Extensions

Markdown Preview comes with Python-Markdown and Markdown2 preloaded.

Python-Markdown

The Python-Markdown Parser provides support for several extensions.

Extra Extensions

You can enable them all at once using the extra keyword.

extensions: [ 'extra' ]

If you want all the extras plus the toc extension,
your settings would look like this:

{
    ...
    parser: 'markdown',
    extensions: ['extra', 'toc'],
    ...
}

Other Extensions

There are also some extensions that are not included in Markdown Extra
but come in the standard Python-Markdown library.

3rd Party Extensions

Python-Markdown is designed to be extended.
Just fork this repo and add your extensions inside the .../Packages/Markdown Preview/markdown/extensions/ folder.

Check out the list of 3rd Party extensions.

Default Extensions

The default extensions are:

Use the default keyword, to select them all.
If you want all the defaults plus the definition_lists extension,
your settings would look like this:

{
    ...
    parser: 'markdown',
    extensions: ['default', 'definition_lists'],
    ...
}

Markdown2

The Markdown2 Parser also provides support for extensions, known as Extras.
You can configure the list of extras you want to use inside the package settings.

Default Extras

The default extras are:

You can enable all default extras at once using the default keyword.
If you want all the default extras plus the 'wiki-table' extra,
your settings would look like this:

{
    ...
    parser: 'markdown2',
    extensions: ['default', 'wiki-table'],
    ...
}

Other Extras

For a complete list of extras please checkout the Extras Wiki Page.

Examples

Tables

The tables extension of the Python-Markdown parser is activated by default,
but is currently not available in Markdown2.

The syntax was adopted from the php markdown project,
and is also used in github flavoured markdown.

Year Temperature (low) Temperature (high)
1900 -10 25
1910 -15 30
1920 -10 32

Wiki Tables

If you are using Markdown2 with the wiki-tables extra activated you should see a table below:

|| Year || Temperature (low) || Temperature (high) ||
|| 1900 || -10 || 25 ||
|| 1910 || -15 || 30 ||
|| 1920 || -10 || 32 ||

Definition Lists

This example requires Python Markdown's def_list extension.

Apple
: Pomaceous fruit of plants of the genus Malus in
the family Rosaceae.

Orange
: The fruit of an evergreen tree of the genus Citrus.

About

This plugin and this sample file is proudly brought to you by the revolunet team


  1. This is the text of the note.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 202,529评论 5 475
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,015评论 2 379
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,409评论 0 335
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,385评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,387评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,466评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,880评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,528评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,727评论 1 295
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,528评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,602评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,302评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,873评论 3 306
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,890评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,132评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,777评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,310评论 2 342

推荐阅读更多精彩内容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 13,424评论 5 6
  • 住 住在下花园的蓝鲸宾馆,条件不错,可是这个季节真是凄凄惨惨戚戚,冷冷清清的寒。暖气没来的日子有点难熬。盖了两床被...
    穆易_生涯咨询师阅读 208评论 2 1
  • 这篇文章仅自己可见 虽然平时神神叨叨的,但我还要强调一句,是我买了十字架的饰品后出门-我朋友就被车擦着了,我被她推...
    大琦zi阅读 167评论 0 0
  • 『壹』 一断浮生情,浮生欢尽,忆清秋,月下孤影醉徘徊,怎念。 二断浮生意,伊人倚门,叹平生,歌花月影尽苍凉,残愿。...
    顾卿绾阅读 686评论 1 3