Sublime Text 2/3 Markdown Previe

2017-01-31  本文已影响0人  lumicinta

SublimePlugin : Markdown Preview

标签(空格分隔): SublimePlugin Markdown

Sublime Text 2/3 Markdown Preview


Sublime Text 2/3 Markdown Preview

Preview and build your markdown files quickly in your web browser from sublime text 2/3.

You can use builtin python-markdown parser or use the github markdown API for the conversion.

NOTE: If you choose the GitHub API for conversion (set parser: github in your settings), your code will be sent through https to github for live conversion. You'll have Github flavored markdown, syntax highlighting and EMOJI support for free :heart: :octocat: :gift:. If you make more than 60 calls a day, be sure to set your GitHub API key in the settings :). You can also get most of this in the default Markdown parser with by enabling certain extensions; see "Parsing Github Flavored Markdown"" below for more information.

LINUX users: If you want to use GitHub API for conversion, you'll need to have a custom Python install that includes python-ssl as its not built in the Sublime Text 2 Linux package. see @dusteye comment. If you use a custom window manager, also be sure to set a BROWSER environment variable. see @PPvG comments

Features :

Installation :

Using Package Control (Recommended)

For all Sublime Text 2/3 users we recommend install via Package Control.

  1. Install Package Control if you haven't yet.
  2. Use <kbd>cmd</kbd>+<kbd>shift</kbd>+<kbd>P</kbd> then Package Control: Install Package
  3. Look for Markdown Preview and install it.

Manual Install

  1. Click the Preferences > Browse Packages… menu
  2. Browse up a folder and then into the Installed Packages/ folder
  3. Download zip package rename it to Markdown Preview.sublime-package and copy it into the Installed Packages/ directory
  4. Restart Sublime Text

Usage :

To preview :

Enabling Other External Markdown Parsers :

External parser commands and arguments should first be mapped to a name. The path to the binary should be first, followed by flags etc.

    "markdown_binary_map": {
        "multimarkdown": ["/usr/local/bin/multimarkdown"]
    },

Then the name can be placed in enabled_parsers to enable use of the new parser.

    "enabled_parsers": ["markdown", "github", "multimarkdown"],

To build :

To config :

Using Sublime Text menu: Preferences->Package Settings->Markdown Preview

Configuring Pygments

If you add the codehilite extension manually in the enabled extensions, you can override some of the default settings.

See codehilte page for more info.

Meta Data Support

When the meta extension is enabled (https://pythonhosted.org/Markdown/extensions/meta_data.html), the results will be written to the HTML head in the form <meta name="key" content="value1,value2">. title is the one exception, and its content will be written to the title tag in the HTML head.

YAML Frontmatter Support

YAML frontmatter can be stripped out and read when strip_yaml_front_matter is set to true in the settings file. In general the, the fronmatter is handled the same as meta data, but if both exist in a file, the YAML keys will override the meta extension keys. There are a few special keys names that won't be handled as html meta data.

Special YAML Key Names

Yaml frontmatter has a few special key names that are used that will not be handled as meta data:

Example

---
    # Builtin values
    references:
        - references.md
        - abbreviations.md
        - footnotes.md

    destination: destination.html

    # Meta Data
    title: Test Page
    author:
        - John Doe
        - Jane Doe

    # Settings overrides
    settings:
        enabled_extensions:
        - extra
        - github
        - toc
        - headerid
        - smarty(smart_quotes=False) # smart quotes interferes with attr_list
        - meta
        - wikilinks
        - admonition
        - codehilite(guess_lang=False,pygments_style=github)
---

Parsing Github Flavored Markdown :

Github Flavored Mardown (GFM) is a very popular markdown. Markdown Preview can actually handle them in a couple of ways: online and offline.

Online :

Parsing GFM using the online method requires using the Github API as the parser. It may also require setting github_mode to gfm to get things like tasklists to render properly. You can set your API key in the settings as follows:

    "github_oauth_token": "secret"

Offline :

By default almost all extensions are enabled to help with the github feel, but there are some tweaks needed to get the full experience.

GFM does not auto guess language in fenced blocks, but Markdown Preview does this by default. You can fix this in one of two ways:

  1. Disable auto language guessing in the settings file "guess_language": false,
  2. Or if you are manually defining extensions: "enabled_extensions": ["codehilite(guess_lang=False,pygments_style=github)"]

As mentioned earlier, almost all extensions are enabled by default, but as a reference, the minimum extensions that should be enabled are listed below:

    "enabled_extensions": [
        "extra",
        "github",
        "codehilite(guess_lang=False,pygments_style=github)"
    ]

This may be further enhanced in the future.

Support :

License :

The code is available at github project under MIT license.

上一篇 下一篇

猜你喜欢

热点阅读