Skip to content

Commit

Permalink
Merge pull request SublimeText-Markdown#348 from SublimeText-Markdown…
Browse files Browse the repository at this point in the history
…/v2.1.7

V2.1.7
  • Loading branch information
felixhao28 authored Jul 20, 2016
2 parents 26cb6d9 + e510eff commit f768453
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 161 deletions.
12 changes: 12 additions & 0 deletions Markdown (Standard).tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,18 @@
<key>include</key>
<string>#inline</string>
</dict>
<dict>
<key>match</key>
<string>\G\s*([*\-+]|[0-9]+\.)\s+</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.list_item.markdown</string>
</dict>
</dict>
</dict>
<dict>
<key>include</key>
<string>text.html.basic</string>
Expand Down
2 changes: 1 addition & 1 deletion Markdown.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@
<key>fenced-obj-c</key>
<dict>
<key>begin</key>
<string>^(\s*[`~]{3,})\s*(objective-c)\s*$</string>
<string>^(\s*[`~]{3,})\s*(obj(ective-)?c)\s*$</string>
<key>end</key>
<string>^(\1)\n</string>
<key>name</key>
Expand Down
2 changes: 1 addition & 1 deletion MarkdownEditor.tmTheme
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<key>invisibles</key>
<string>#E0E0E0</string>
<key>lineHighlight</key>
<string>#e6e6e6</string>
<string>#B6B6B6</string>
<key>selection</key>
<string>#C2E8FF</string>
<key>selectionBorder</key>
Expand Down
2 changes: 1 addition & 1 deletion MultiMarkdown.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<array>
<dict>
<key>begin</key>
<string>^([A-Za-z0-9]+)(:)\s*</string>
<string>^([A-Za-z0-9 _\-]+)(:)\s*</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand Down
64 changes: 32 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,49 @@ Markdown plugin for Sublime Text. Provides a decent Markdown color scheme (light

## Overview

* [Installation](#installation)
* [Features](#features)
* [Key Bindings](#key-bindings)
* [GFM Specific Features](#gfm-specific-features)
* [Commands for Command Palette](#commands-for-command-palette)
* [Installation](#installation)
* [Configuration](#configuration)
* [Tips](#tips)
* [Similar Plugins](#similar-plugins)
* [Known Bugs](#known-bugs)
* [Contributing](#contributing)
* [Credits](#credits)
* [Donation](#donation)
* [License](#license)
* [License](#license)

## Installation

> __Important Note About 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][wbond].

1. [Install Sublime Package Control][wbond 2]
2. From inside Sublime Text, open Package Control's Command Pallet: <kbd>CTRL</kbd> <kbd>SHIFT</kbd> <kbd>P</kbd> (Windows, Linux) or <kbd>CMD</kbd> <kbd>SHIFT</kbd> <kbd>P</kbd> 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

1. 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`
2. Restart Sublime Text to complete installation. Open a Markdown file and this custom theme. The features listed above should now be available.

## Features

Expand Down Expand Up @@ -96,36 +126,6 @@ Performs lint on current Markdown file. See [lint rules](lint_docs/RULES.md). So

Switches the highlighted list between numbered and bulleted style.

## Installation

> __Important Note About 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][wbond].

1. [Install Sublime Package Control][wbond 2]
2. From inside Sublime Text, open Package Control's Command Pallet: <kbd>CTRL</kbd> <kbd>SHIFT</kbd> <kbd>P</kbd> (Windows, Linux) or <kbd>CMD</kbd> <kbd>SHIFT</kbd> <kbd>P</kbd> 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

1. 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`
2. 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.
Expand Down
2 changes: 1 addition & 1 deletion decide_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ def on_modified_async(self, view):
break

title = title.strip()
if view.file_name() is None and len(title) > 0:
if view.file_name() is None and view.name() is None and len(title) > 0:
view.set_name(title[:55])
12 changes: 12 additions & 0 deletions messages/2.1.7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# MarkdownEditing 2.1.7 Changelog

Your _MarkdownEditing_ plugin is updated. Enjoy new version. For any type of
feedback you can use [GitHub issues][issues].

## Bug Fixes

## New Features

## Changes

[issues]: https://github.com/SublimeText-Markdown/MarkdownEditing/issues
60 changes: 30 additions & 30 deletions numbered_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@
import re

class NumberListCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
sel = view.sel()[0]
text = view.substr(view.full_line(sel))
num = re.search('\d', text).start()
dot = text.find(".")
additional_spaces = re.search(r"^\s*", text[dot+1:]).group()
increment = 0
if self.view.settings().get('mde.auto_increment_ordered_list_number', True):
increment = 1
if num == 0:
view.erase(edit, sel)
view.insert(edit, sel.begin(), "\n%d.%s" % (int(text[:dot]) + increment, additional_spaces))
else:
view.erase(edit, sel)
view.insert(edit, sel.begin(), "\n%s%d.%s" % (text[:num], int(text[num:dot]) + increment, additional_spaces))
def run(self, edit):
view = self.view
sel = view.sel()[0]
text = view.substr(view.full_line(sel))
num = re.search('\d', text).start()
dot = text.find(".")
additional_spaces = re.search(r"^\s*", text[dot+1:]).group()
increment = 0
if self.view.settings().get('mde.auto_increment_ordered_list_number', True):
increment = 1
if num == 0:
view.erase(edit, sel)
view.insert(edit, sel.begin(), "\n%d.%s" % (int(text[:dot]) + increment, additional_spaces))
else:
view.erase(edit, sel)
view.insert(edit, sel.begin(), "\n%s%d.%s" % (text[:num], int(text[num:dot]) + increment, additional_spaces))

def is_enabled(self):
return bool(self.view.score_selector(self.view.sel()[0].a, "text.html.markdown"))
def is_enabled(self):
return bool(self.view.score_selector(self.view.sel()[0].a, "text.html.markdown"))

class NumberListReferenceCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
sel = view.sel()[0]
text = view.substr(view.full_line(sel))
num = re.search('\d', text).start()
dot = text.find("]")
if num == 0:
view.erase(edit, sel)
view.insert(edit, sel.begin(), "\n%d]: " % (int(text[:dot]) + 1,))
else:
view.erase(edit, sel)
view.insert(edit, sel.begin(), "\n%s%d]: " % (text[:num], int(text[num:dot]) + 1))
def run(self, edit):
view = self.view
sel = view.sel()[0]
text = view.substr(view.full_line(sel))
num = re.search('\d', text).start()
dot = text.find("]")
if num == 0:
view.erase(edit, sel)
view.insert(edit, sel.begin(), "\n%d]: " % (int(text[:dot]) + 1,))
else:
view.erase(edit, sel)
view.insert(edit, sel.begin(), "\n%s%d]: " % (text[:num], int(text[num:dot]) + 1))
8 changes: 8 additions & 0 deletions snippets/Markdown_codeblock_(mdc).sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<snippet>
<content><![CDATA[```${1:language}
${2:code}
```]]></content>
<tabTrigger>mdc</tabTrigger>
<scope>text.html.markdown.multimarkdown, text.html.markdown</scope>
<description>Markdown Codeblock</description>
</snippet>
13 changes: 9 additions & 4 deletions switch_list_bullet_type.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
import sublime_plugin
import re


class SwitchListBulletTypeCommand(sublime_plugin.TextCommand):

def run(self, edit):
todo = []
for region in self.view.sel():
lines = self.view.line(region)
lines = self.view.split_by_newlines(lines)
number = 1
for line in lines:
line_content = self.view.substr(line)
# print(line_content)
m = re.match(r"^(\s*(?:>\s*)?)[*+\-](\s+.*)$", line_content)
if m:
# Transform the bullet to numbered bullet type
new_line = m.group(1) + "1." + m.group(2)
new_line = m.group(1) + str(number) + "." + m.group(2)
if self.view.settings().get('mde.auto_increment_ordered_list_number', True):
number += 1

# Insert the new item
todo.append([line, new_line])
else:
m = re.match(r"^(\s*(?:>\s*)?)[0-9]+\.(\s+.*)$", line_content)
m = re.match(
r"^(\s*(?:>\s*)?)[0-9]+\.(\s+.*)$", line_content)
if m:
marker = self.view.settings().get('mde.list_indent_bullets', ["*"])
# Transform the bullet to unnumbered bullet type
new_line = m.group(1) + "-" + m.group(2)
new_line = m.group(1) + marker[0] + m.group(2)

# Insert the new item
todo.append([line, new_line])


while len(todo) > 0:
j = todo.pop()
self.view.replace(edit, j[0], j[1])
Expand Down
Loading

0 comments on commit f768453

Please sign in to comment.