美文网首页其他
Markdown初使用

Markdown初使用

作者: 李司徒 | 来源:发表于2013-10-16 15:13 被阅读188次

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 logorevolunet logo

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

revolunet logorevolunet 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.

相关文章

  • Markdown初使用

    笔者也是刚刚接触Markdown,因此笔者在这里总结了使用Markdown的有关知识与方法。 为什么要学习和使用 ...

  • Markdown初使用

    Sample Markdown Cheat Sheet This is a sample markdown fil...

  • 2018-08-31

    常见的Markdown编辑器中数学公式使用 相比于初入Markdown编辑器的小白来说,数学公式的使用是必须要掌握...

  • Markdown初学笔记

    初来简书,发现很多人都推荐使用Markdown编辑器,之前都没有听说过这种语言。今晚决定抽空学习Markdown,...

  • Markdown初入门(使用Typora编辑)

    标题使用#来实现标题的大小控制# h1 标题1## h2 标题2### ...

  • 2019-01-14

    markdown 使用 markdown 地址:[https://http://www.markdown.cn/...

  • MarkDown使用指南

    标题使用‘##’ 黑体使用'?' 斜体使用'?' 无序列表(*-) markdown好用吗? markdown怎么...

  • 2020-01-09

    MarkDown目录使用 1.MarkDown标题 MarkDown标题链接跳转

  • Markdown帮助文档(CSDN官方更新版)- Markdow

    标题:本文主要是「Markdown整体介绍」 欢迎使用Markdown编辑器 你好! 这是你使用 Markdown...

  • 无标题文章

    #**Markdown 使用手记**###1. 什么是 Markdown>**[Markdown](https:/...

网友评论

    本文标题:Markdown初使用

    本文链接:https://www.haomeiwen.com/subject/eglqtttx.html