1252人阅读 评论(0)

# Package Control Messages

## Markdown Preview

Sublime Text 2/3 Markdown Preview
=================================

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 :

• Markdown preview using the Python-markdown or the Github API just choose select the build commands.
• Build markdown file using Sublime Text build system. The build parser are config via the "parser" config.
• Browser preview auto reload on save if you have the ST2 LiveReload plugin installed.
• Builtin parser : supports abbr, attr_list, def_list, fenced_code, footnotes, tables, smart_strong, smarty, wikilinks, meta, sane_lists, codehilite, nl2br, and toc markdown extensions.
• CSS search path for local and build-in CSS files (always enabled) and/or CSS overriding if you need
• YAML support thanks to @tommi
• Clipboard selection and copy to clipboard thanks to @hexatrope
• MathJax support : π2$\frac{\pi}{2}$ thanks to @bps10
• HTML template customisation thanks to @hozaka
• Strip out multimarkdown critic marks (see settings file for more info)
• 3rd party extensions for the Python Markdown parser:

Extension Documentation
delete Surround inline text with crossed out to get del tags crossed out.
insert Surround inline text with ^^underlined^^ to get ins tags underlined.
githubemoji Support for Github Flavored Markdown emojis (GithubEmoji Documentation).
github A convenience extension to add: magiclink, delete, tasklist, githubemoji, headeranchor, superfences, and nl2br to parse and display Markdown in a github-ish way. It is recommed to pair github with extra and codehilite (with language guessing off) to parse close to github’s way. Be aware of what extensions github loads, because you should not load extensions more than once.
progressbar Create progress bars (ProgressBar Documentation).
superfences Allow fenced blocks to be nested under lists, blockquotes, etc. and add special UML diagram blocks (SuperFences Documentation).

## Installation :

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

1. Install Package Control if you haven’t yet.
2. Use cmd+shift+P 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 :

• optionally select some of your markdown for conversion

• use cmd+shift+P then Markdown Preview to show the follow commands (you will be prompted to select which parser you prefer):
• Markdown Preview: Preview in Browser
• Markdown Preview: Export HTML in Sublime Text
• Markdown Preview: Copy to Clipboard
• Markdown Preview: Open Markdown Cheat sheet
• or bind some key in your user key binding, using a line like this one:
{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"} }, for a specific parser and target or { "keys": ["alt+m"], "command": "markdown_preview_select", "args": {"target": "browser"} }, to bring up the quick panel to select enabled parsers for a given target.
• once converted a first time, the output HTML will be updated on each file save (with LiveReload plugin)

### To build :

• Just use Ctrl+B (Windows/Linux) or cmd+B (Mac) to build current file.

### To config :

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

• Settings - User is where you change your settings for Markdown Preview.
• Settings - Default is a good reference with detailed descriptions for each setting.

### Configuring Pygments

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

• Turn language guessing on or off (on will highlight fenced blocks even if you don’t specify a language) codehilite(guess_lang=False) (True|False).
• Show line numbers: codehilite(linenums=True) (True|False).
• Change the higlight theme: codehilite(pygments_style=emacs).
• Inline the CSS: codehilite(noclasses=True) (True|False).
• Use multiple: codehilite(linenums=True, pygments_style-emacs).

### 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:

• basepath: An absolute path to configure the relative paths for images etc. (for when the markdown is supposed to reference images in a different location.)
• references: Can take a file path or an array of file paths for separate markdown files containing references, footnotes, etc. Can be an absolute path or relative path. Relative paths first use the source file’s directory, and if the file cannot be found, it will use the basepath setting.
• destination: This is an absolute file path or relative file path for when the markdown is saved to html via the build command or the Save to HTML command. Relative paths first use the source file’s directory, and if the file cannot be found, it will use the basepath setting.
• settings: This is a dictionary where you can override settings that are in the settings file.

#### Example

<hr />

# 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
- smarty(smart_quotes=False) # smart quotes interferes with attr_list
- meta
- codehilite(guess_lang=False,pygments_style=github)
<hr />


### 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.

#### 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 :

• Any bugs about Markdown Preview please feel free to report here.
• And you are welcome to fork and submit pullrequests.

The code is available at github project under MIT licence.

## MarkdownEditing

# MarkdownEditing

Markdown plugin for Sublime Text. Provides a decent Markdown color scheme (light and dark) with more robust syntax highlighting and useful Markdown editing features for Sublime Text. 3 flavors are supported: Standard Markdown, GitHub flavored Markdown, MultiMarkdown.

Dark and yellow theme available.

## Overview

• Features
• Key Bindings
• GFM Specific Features
• Commands for Command Palette
• Installation
• Configuration
• Tips
• Similar Plugins
• Known Bugs
• Contributing
• Credits
• Donation

## Features

• Asterisks and underscores are autopaired and will wrap selected text

• If you start an empty pair and hit backspace, both elements are deleted
• If you start an empty pair and hit space, the right element is deleted
• Backticks are paired
• At the end of a list item, pressing Enter will automatically insert the new list item bullet.
• Pressing Tab on the blank list item will indent it and switch the list bullet to another one (Order is *, -, + in a cycle).
• Pressing Shift Tab on the blank list item will unindent it in the same way as above.
• Sequential Tab s or Shift Tab s are supported.
• You can disable automatic bullet switching or choose which bullets to be used, in your settings file.
• If a list item contains a GFM task, pressing Enter at the end of the line will continue with a new blank task.
• At the end of a blockquote line, pressing Enter will automatically extend blockquote.
• Selecting some text and pressing > will convert it to blockquote. The first and the last line don’t have to be fully selected; partial select works, too.
• Left bracket pairing is modified to eliminate the selection and leave the cursor at a point where you can insert a [] or () pair for a link
• Displays Markdown headers in the Project Symbol List (Ctrl Shift R). They will start with #, so you will know they belong to markdown files at a glance. Also they will be on top of the list because of the presedence of #.
• ~ wraps selected text with ~~ (strikethrough).
• Typing # when there’s a selection will surround it with # to make it a headline. Multiple presses add additional hashes, increasing the level of the header. Once you hit 6 hashes, it will reset to 0 on the next press. The mde.match_header_hashes will determine if the # are mirrored on both sides or just at the beginning of the line.
• Typing return at the end of a line that begins with hashmarks will insert closing hashmarks on the headline. They’re not required for Markdown, it’s just aesthetics, and you can change the mde.match_header_hashes option in your settings to disable.
• Setext-style headers can be completed with Tab. That is, typing Tab on a line containing only = or - characters will add or remove enough characters to it to match the length of the line above.
• New documents will be named automatically based on the first header.

## Key Bindings

OS X Windows/Linux Description
V CtrlWinV Pastes the contents of the clipboard as an inline link on selected text.
R CtrlWinR Pastes the contents of the clipboard as a reference link.
K CtrlWinK Inserts a standard inline link.
K ShiftWinK Inserts an inline image.
B I CtrlShiftB CtrlShiftI These are bound to bold and italic. They work both with and without selections. If there is no selection, they will just transform the word under the cursor. These keybindings will unbold/unitalicize selection if it is already bold/italic.
^1...6 Ctrl1...6 These will add the corresponding number of hashmarks for headlines. Works on blank lines and selected text in tandem with the above headline tools. If you select an entire existing headline, the current hashmarks will be removed and replaced with the header level you requested. This command respects the mde.match_header_hashes preference setting.
6 CtrlShift6 Inserts a footnote and jump to its definition. If your cursor is in a definition, it will jump back to the marker.
F AltShiftF Locates footnote markers without definitions and inserts their markers for the definition.
G AltShiftG Locates link references without definitions and inserts their labels at the bottom for the definition.

## GFM Specific Features

Underscores in words doesn’t mess with bold or italic style:

Fenced code blocks gets syntax highlighting inside:

Keyboard shortcuts gets highlighted like in GitHub:

Strikethrough is supported:

## Commands for Command Palette

Adjusts every setext-style header to add or remove = or - characters as needed to match the lengths of their header text.

### Convert Underlined Headers to ATX

Converts every setext-style header into an ATX style header. If something is selected only the headers in the selections will be converted, otherwise the conversion will be applied to the whole view.

Scans document for referenced link usages ([some link][some_ref] and [some link][]) and checks if they are all defined. If there are undefined link references, command will automatically create their definition snippet at the bottom of the file.

### Markdown Lint

Performs lint on current Markdown file. See lint rules. Some of the linting rules are customizable via user settings file.

### Switch List Bullet Type

Switches the highlighted list between numbered and bulleted style.

## Installation

Are you getting this error after installation: Error loading syntax file “Packages/Markdown/Markdown.tmLanguage”: Unable to open Packages/Markdown/Markdown.tmLanguage? This is caused by open markdown files at the install time. You have to manually change their syntax to your newly installed Markdown syntax. Read the below paragraph for more details on this.

Note: Sublime text has a native tiny package for Markdown. However, when MarkdownEditing is enabled, native package causes some conflicts. For this reason, MarkdownEditing will automatically disable it. Since it doesn’t bring anything new over MarkdownEditing, this is not a loss. But remember, when you disable MarkdownEditing, you have to reenable the native one manually (if you want).

If you are using Sublime Text 2, you have to disable the native package manually. To do that, add Markdown to your ignored_packages list in ST user settings:

  "ignored_packages": [..., "Markdown"],


### Package Control

The preferred method of installation is via Sublime Package Control.

1. Install Sublime Package Control
2. From inside Sublime Text, open Package Control’s Command Pallet: CTRL SHIFT P (Windows, Linux) or CMD SHIFT P on Mac.
3. Type install package and hit Return. A list of available packages will be displayed.
4. Type MarkdownEditing and hit Return. The package will be downloaded to the appropriate directory.
5. Restart Sublime Text to complete installation. Open a Markdown file and this custom theme. The features listed above should now be available.

### Manual Installation

6. Download or clone this repository to a directory MarkdownEditing in the Sublime Text Packages directory for your platform:

• Mac: git clone https://github.com/SublimeText-Markdown/MarkdownEditing.git ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/MarkdownEditing
• Windows: git clone https://github.com/SublimeText-Markdown/MarkdownEditing.git %APPDATA%\Sublime/ Text/ 2/\MarkdownEditing
• Linux: git clone https://github.com/SublimeText-Markdown/MarkdownEditing.git ~/.Sublime\ Text\ 2/Packages/MarkdownEditing
7. Restart Sublime Text to complete installation. Open a Markdown file and this custom theme. The features listed above should now be available.

## Configuration

The plugin contains 3 different Markdown flavors: Standard Markdown, GitHub flavored Markdown, MultiMarkdown. Default is GitHub flavored Markdown. If you want to set another one as default, open a Markdown file and select your flavor from the menu: View > Syntax > Open all with current extension as. You’re done.

You may want to have a look at the default settings files. They are located at:

Packages/MarkdownEditing/Markdown.sublime-settings [GitHub flavored Markdown]
Packages/MarkdownEditing/Markdown (Standard).sublime-settings
Packages/MarkdownEditing/MultiMarkdown.sublime-settings

If you want to override any of the default settings, you can open the appropriate user settings file using the Preferences > Package Settings > Markdown Editing menu. Each flavor has a different settings file.

Bold and italic markers are configurable through ST shell variables. You can use Preferences > Package Settings > Markdown Editing menu to see the default settings file. In order to override it, copy & paste its content into the user settings file (Packages/User/Bold and Italic Markers.tmPreferences) from the menu and make your edits. It is pretty straightforward.

In order to activate the dark or the yellow theme, put one of these lines to your user settings file of the flavor (Packages/User/[flavor].sublime-settings):

“color_scheme”: “Packages/MarkdownEditing/MarkdownEditor-Dark.tmTheme”,
“color_scheme”: “Packages/MarkdownEditing/MarkdownEditor-Yellow.tmTheme”,

If you want to go with your already existing theme, you can reenable it with the same method as above. Keep in mind that, that theme may not cover all the parts of the Markdown syntax that this plugin defines.

By default, when you install the plugin, files with these extensions will be assigned to Markdown syntax: “md”, “txt”, “mdown”, “markdown”, “markdn”. If you want to prevent any of these extensions to be opened as Markdown, follow these steps:

8. Click on the language menu at bottom right

9. Select “Open all with current extension as”
10. Choose your preferred syntax for that extension

## Tips

We are maintaining a tips section in our Wiki. Jump there to learn from others or share your experiences with others.

## Similar Plugins

• Knockdown

Knockdown offers useful Markdown features and a custom Markdown theme. All of its unique features except its theme are ported to MarkdownEditing and some of them are actually improved further in MarkdownEditing.

• Sublime Markdown Extended
• SmartMarkdown

## Known Bugs

• Setext-style headers (=== and ---) do not show up in the symbol list. This is due to a Sublime Text limitation (see #158). However, we are able to put a placeholder to indicate the existence of the header. We encourage you to use Atx-style headers (#).

• Installing for the first time while having markdown files opened may cause MarkdownEditing to behave unexpectedly on those files. Close and reopen those files to fix it.

## Contributing

See CONTRIBUTING.md file.

## Credits

MarkdownEditing was originally created by Brett Terpstra and has become a community project with the goal of consolidating the best features from the varied collection of Markdown packages for Sublime Text. Current development is headed up by Ali Ayas.

Related blog posts from Brett:

This plugin contains portions of code from Knockdown.

Footnote commands were submitted by J. Nicholas Geist and originated at geekabouttown.

## Donation

You can support contributors of this project individually. Every contributor is welcomed to add his/her line below with any content. Ordering shall be alphabetically by GitHub username.

MarkdownEditing is released under the MIT License.

0
0

个人资料
• 访问：234582次
• 积分：4882
• 等级：
• 排名：第6965名
• 原创：204篇
• 转载：20篇
• 译文：13篇
• 评论：35条
个人专链
博客专栏
 剑指offer-Java 文章：43篇 阅读：12916
 MySQL 5.6 参考 文章：8篇 阅读：7140
 Delphi 7.0 学习历程 文章：12篇 阅读：15598
最新评论