Skip to content

Commit

Permalink
Merge branch '3.0.3' into st3176
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Sep 19, 2021
2 parents 1cc6d7d + c254a14 commit 79790ed
Show file tree
Hide file tree
Showing 25 changed files with 1,326 additions and 779 deletions.
132 changes: 71 additions & 61 deletions Default (Linux).sublime-keymap

Large diffs are not rendered by default.

132 changes: 71 additions & 61 deletions Default (OSX).sublime-keymap

Large diffs are not rendered by default.

132 changes: 71 additions & 61 deletions Default (Windows).sublime-keymap

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion Preferences.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"mde.auto_fold_link.enabled": true,
// MarkdownEditing (Folding):
// Selector for urls to automatically fold
"mde.auto_fold_link.selector": "( meta.image | meta.link ) & ( markup.underline | constant.other) - meta.link.reference.footnote - meta.link.reference.def - meta.link.inet",
"mde.auto_fold_link.selector": "( meta.image.inline.metadata.markdown | meta.image.reference.metadata.markdown | meta.link.inline.metadata.markdown | meta.link.reference.metadata.markdown ) - punctuation.definition.metadata",

// MarkdownEditing (Wiki):
// wiki file extensions
Expand All @@ -125,6 +125,10 @@

// You can opt out some keybinds by setting the corresponding value from 'false' to 'true' (without single-quotes).
// Super key references to a key next to left Alt key. It usually has a Windows logo or "win" or "Command" on it.

// Set Heading Level
// Default keys: (OSX/Linux/Win): alt+k, alt+0..9
"mde.keymap_disable.set_heading_level": false,
// Jump between link/image/footnote reference and definition
// Default keys: (OSX)super+ctrl+shift+l (Linux/Win)ctrl+alt+g
"mde.keymap_disable.reference_jump": false,
Expand Down
6 changes: 4 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ or use one of the following bindings:

| Linux/Windows | MacOS | Description
|---------------|-------|-------------
| <kbd>ctrl</kbd> + <kbd>alt</kbd> + <kbd>0</kbd> | <kbd></kbd> + <kbd>^</kbd> + <kbd>0</kbd> | convert headings into normal text
| <kbd>ctrl</kbd> + <kbd>alt</kbd> + <kbd>1..6</kbd> | <kbd></kbd> + <kbd>^</kbd> + <kbd>1..6</kbd> | set headings level to 1..6
| <kbd>alt</kbd> + <kbd>k</kbd>, <kbd>alt</kbd> + <kbd>0</kbd> | <kbd>^</kbd> + <kbd>k</kbd>, <kbd>^</kbd> + <kbd>0</kbd> | convert headings into normal text
| <kbd>alt</kbd> + <kbd>k</kbd>, <kbd>alt</kbd> + <kbd>1..6</kbd> | <kbd>^</kbd> + <kbd>k</kbd>, <kbd>^</kbd> + <kbd>1..6</kbd> | set headings level to 1..6
| <kbd>ctrl</kbd> + <kbd>alt</kbd> + <kbd>,</kbd> | <kbd>⌘</kbd> + <kbd>^</kbd> + <kbd>,</kbd> | reduce headings level by one
| <kbd>ctrl</kbd> + <kbd>alt</kbd> + <kbd>.</kbd> | <kbd>⌘</kbd> + <kbd>^</kbd> + <kbd>.</kbd> | increase headings level by one

Key bindings can be disabled via `"mde.keymap_disable.set_heading_level": true`.

Adding or removing `#` at the beginning of lines also modifies heading levels implicitly while maintaining open or closed heading styles.

### Constraints
Expand Down
3 changes: 1 addition & 2 deletions macros/Transform Word - Bold (Asterisk).sublime-macro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[
{"command": "expand_selection", "args": {"to": "word"}},
{"command": "insert_snippet", "args": {"contents": "**${SELECTION/^\\*\\*|^__|\\*\\*$|__$//g}**"}},
{"command": "move", "args": {"by": "words", "forward": false}}
{"command": "insert_snippet", "args": {"contents": "**${SELECTION/^\\*\\*|^__|\\*\\*$|__$//g}**"}}
]
3 changes: 1 addition & 2 deletions macros/Transform Word - Bold (Underscore).sublime-macro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[
{"command": "expand_selection", "args": {"to": "word"}},
{"command": "insert_snippet", "args": {"contents": "__${SELECTION/^\\*\\*|^__|\\*\\*$|__$//g}__"}},
{"command": "move", "args": {"by": "words", "forward": false}}
{"command": "insert_snippet", "args": {"contents": "__${SELECTION/^\\*\\*|^__|\\*\\*$|__$//g}__"}}
]
3 changes: 1 addition & 2 deletions macros/Transform Word - Italic (Asterisk).sublime-macro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[
{"command": "expand_selection", "args": {"to": "word"}},
{"command": "insert_snippet", "args": {"contents": "*${SELECTION/^(\\*{2}|_{2})?([*_])(.+)([*_])(\\*{2}|_{2})?$/$1$3$1/g}*"}},
{"command": "move", "args": {"by": "words", "forward": false}}
{"command": "insert_snippet", "args": {"contents": "*${SELECTION/^(\\*{2}|_{2})?([*_])(.+)([*_])(\\*{2}|_{2})?$/$1$3$1/g}*"}}
]
3 changes: 1 addition & 2 deletions macros/Transform Word - Italic (Underscore).sublime-macro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[
{"command": "expand_selection", "args": {"to": "word"}},
{"command": "insert_snippet", "args": {"contents": "_${SELECTION/^(\\*{2}|_{2})?([*_])(.+)([*_])(\\*{2}|_{2})?$/$1$3$1/g}_"}},
{"command": "move", "args": {"by": "words", "forward": false}}
{"command": "insert_snippet", "args": {"contents": "_${SELECTION/^(\\*{2}|_{2})?([*_])(.+)([*_])(\\*{2}|_{2})?$/$1$3$1/g}_"}}
]
5 changes: 5 additions & 0 deletions macros/Transform Word - Unbold Bold Italics.sublime-macro
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{"command": "expand_selection", "args": {"to": "scope"}},
{"command": "expand_selection", "args": {"to": "scope"}},
{"command": "insert_snippet", "args": {"contents": "${SELECTION/^\\*\\*|^__|\\*\\*$|__$//g}"}}
]
3 changes: 1 addition & 2 deletions macros/Transform Word - Unbold.sublime-macro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[
{"command": "expand_selection", "args": {"to": "scope"}},
{"command": "insert_snippet", "args": {"contents": "${SELECTION/^\\*\\*|^__|\\*\\*$|__$//g}"}},
{"command": "move", "args": {"by": "words", "forward": false}}
{"command": "insert_snippet", "args": {"contents": "${SELECTION/^\\*\\*|^__|\\*\\*$|__$//g}"}}
]
3 changes: 1 addition & 2 deletions macros/Transform Word - Unitalicize.sublime-macro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[
{"command": "expand_selection", "args": {"to": "scope"}},
{"command": "insert_snippet", "args": {"contents": "${SELECTION/^(?:(\\*{2}|_{2})?([*_])|([*_])(\\*{2}|_{2})?)(\\S(?:.*\\S))(?:(\\2)(\\1)|(\\4)?(\\3))$/$1$4$5$7$8/g}"}},
{"command": "move", "args": {"by": "words", "forward": false}}
{"command": "insert_snippet", "args": {"contents": "${SELECTION/^(?:(\\*{2}|_{2})?([*_])|([*_])(\\*{2}|_{2})?)(\\S(?:.*\\S))(?:(\\2)(\\1)|(\\4)?(\\3))$/$1$4$5$7$8/g}"}}
]
32 changes: 32 additions & 0 deletions messages/3.0.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# MarkdownEditing 3.0.3 Changelog

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

## Bug Fixes

* Tweak auto link folding selector (fixes #624)
* Use correct selector for open page key binding (fixes #629)
* Restore Goto Link Reference/Definition functionality (fixes #632)
* Refactor image/link/reference syntax definitions (fixes #633)
* Don't hide inline code-span punctuation im Mariana/Monokai (fixes #633)
* Resolve `AltGr` key binding conflicts (fixes #634)
* Don't move caret to beginning of word after changing formatting (fixes #636)
* Adding task via `alt+t` respects `mde.list_indent_bullets` setting (fixes #636)
* Bootstrapper reassigns Markdown syntaxes from any location
* Bootstrapper removes invalid syntax specific color scheme settings
* Color Scheme Selector correctly detects 'auto' color scheme
* Remove obsolete keymap selectors (required due to recent syntax changes)
* Add a macro to unbold bold italc text (required due to recent syntax changes)
* Only strip whitespace separated trailing hashes of headings from symbol lists
* Scope inet/email autolinks according to CommonMark 0.30.0

## New Features

* Scope path separators and escapes in urls
* Support fish fenced code (if supported syntax is installed)
* Partially support xonsh fenced code (use Python syntax due to a lack of xonsh syntax support in ST)

## Changes

[issues]: https://github.com/SublimeText-Markdown/MarkdownEditing/issues
1 change: 1 addition & 0 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
MdeUnindentListItemCommand,
MdeNumberListCommand,
MdeSwitchListBulletTypeCommand,
MdeInsertTaskListItemCommand,
MdeToggleTaskListItemCommand,
MdeJoinLines,
)
Expand Down
66 changes: 42 additions & 24 deletions plugins/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import sublime

from .color_schemes import clear_color_schemes, select_color_scheme
from .color_schemes import clear_color_schemes, clear_invalid_color_schemes, select_color_scheme

BOOTSTRAP_VERSION = "3.0.2"
BOOTSTRAP_VERSION = "3.0.3"

package_name = "MarkdownEditing"

Expand All @@ -25,14 +25,6 @@ def save_ingored_packages(ignored_packages):
def disable_native_markdown_package():
ignored_packages = get_ingored_packages()
if "Markdown" not in ignored_packages:
reassign_syntax(
"Packages/Markdown/Markdown.sublime-syntax",
"Packages/MarkdownEditing/syntaxes/Markdown.sublime-syntax",
)
reassign_syntax(
"Packages/Markdown/MultiMarkdown.sublime-syntax",
"Packages/MarkdownEditing/syntaxes/MultiMarkdown.sublime-syntax",
)
ignored_packages.append("Markdown")
save_ingored_packages(ignored_packages)

Expand All @@ -45,11 +37,11 @@ def enable_native_markdown_package():

def reassign():
reassign_syntax(
"Packages/MarkdownEditing/syntaxes/Markdown.sublime-syntax",
"Markdown.sublime-syntax",
"Packages/Markdown/Markdown.sublime-syntax",
)
reassign_syntax(
"Packages/MarkdownEditing/syntaxes/MultiMarkdown.sublime-syntax",
"MultiMarkdown.sublime-syntax",
"Packages/Markdown/MultiMarkdown.sublime-syntax",
)

Expand All @@ -60,10 +52,39 @@ def reassign_syntax(current_syntax, new_syntax):
for window in sublime.windows():
for view in window.views():
syntax = view.settings().get("syntax")
if syntax and syntax == current_syntax:
if syntax and syntax.endswith(current_syntax) and syntax != new_syntax:
view.assign_syntax(new_syntax)


def bootstrap_syntax_assignments():
"""
Reassign syntax to all open Markdown, MultiMarkdown or Plain Text files.
Repair syntax assignments of open views after install or upgrade, in case
old ones no longer exist.
"""
markdown = "Packages/MarkdownEditing/syntaxes/Markdown.sublime-syntax"
multimarkdown = "Packages/MarkdownEditing/syntaxes/MultiMarkdown.sublime-syntax"

for window in sublime.windows():
for view in window.views():
syntax = view.settings().get("syntax")
if syntax:
syntax = os.path.basename(syntax)
if syntax in ("Markdown.tmLanguage", "Markdown.sublime-syntax"):
view.assign_syntax(markdown)
continue
if syntax in ("MultiMarkdown.tmLanguage", "MultiMarkdown.sublime-syntax"):
view.assign_syntax(multimarkdown)
continue

file_name = view.file_name()
if file_name:
_, ext = os.path.splitext(file_name)
if ext in (".md", ".mdown", ".markdown"):
view.assign_syntax(markdown)


def on_after_install():
cache_path = os.path.join(sublime.cache_path(), "MarkdownEditing")
bootstrapped = os.path.join(cache_path, "bootstrapped")
Expand All @@ -79,19 +100,16 @@ def on_after_install():
shutil.rmtree(cache_path, ignore_errors=True)
os.makedirs(cache_path, exist_ok=True)

# remove wrong bootstrapped cookie file created by 3.0.1
try:
os.remove(os.path.join(sublime.packages_path(), "User", "MarkdownEditing.sublime-syntax"))
except FileNotFoundError:
pass
def async_worker():
bootstrap_syntax_assignments()
disable_native_markdown_package()
clear_invalid_color_schemes()
# Update bootstrap cookie.
open(bootstrapped, "w").write(BOOTSTRAP_VERSION)

# Native package causes some conflicts.
disable_native_markdown_package()
# Prompts to select a color scheme.
sublime.set_timeout_async(select_color_scheme, 500)
select_color_scheme()

# Update bootstrap cookie.
open(bootstrapped, "w").write(BOOTSTRAP_VERSION)
sublime.set_timeout_async(async_worker, 200)


def on_before_uninstall():
Expand Down
25 changes: 23 additions & 2 deletions plugins/color_schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ def select_color_scheme(view=None):
schemes_display = []
selected_index = 0
for i, s in enumerate(schemes):
m = re.search(r"[^/]+(?=\.(sublime-color-scheme|tmTheme)$)", s)
theme_display = m.group(0)
if s == "auto":
theme_display = "Auto"
else:
m = re.search(r"[^/]+(?=\.(sublime-color-scheme|tmTheme)$)", s)
theme_display = m.group(0)
if s == global_scheme:
theme_display += " (Global)"
if not md_scheme:
Expand Down Expand Up @@ -95,3 +98,21 @@ def clear_color_scheme(filename):
settings = sublime.load_settings(filename)
settings.erase("color_scheme")
sublime.save_settings(filename)


def clear_invalid_color_schemes():
clear_invalid_color_scheme("Markdown.sublime-settings")
clear_invalid_color_scheme("Markdown GFM.sublime-settings")
clear_invalid_color_scheme("MultiMarkdown.sublime-settings")


def clear_invalid_color_scheme(filename):
settings = sublime.load_settings(filename)
color_scheme = settings.get("color_scheme")
if not color_scheme:
return
try:
sublime.load_resource(color_scheme)
except FileNotFoundError:
settings.erase("color_scheme")
sublime.save_settings(filename)
21 changes: 21 additions & 0 deletions plugins/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,27 @@ def run(self, edit):
view.insert(edit, sel.begin(), to_insert)


class MdeInsertTaskListItemCommand(MdeTextCommand):
"""
The `mde_insert_task_list_item` command inserts a new GFM task.
It respects the primary bullet set via `"mde.list_indent_bullets"` setting.
"""

def run(self, edit):
align_text = self.view.settings().get("mde.list_align_text", True)
bullets = self.view.settings().get("mde.list_indent_bullets", ["*", "-", "+"])

to_insert = "{} [ ]".format(bullets[0])
if align_text:
to_insert += "\t"
else:
to_insert += " "

for sel in self.view.sel():
self.view.insert(edit, sel.begin(), to_insert)


class MdeToggleTaskListItemCommand(MdeTextCommand):
"""
The `mde_toggle_task_list_item` command toggles the check mark of task list items.
Expand Down
18 changes: 9 additions & 9 deletions plugins/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
from .view import MdeTextCommand
from .view import MdeViewEventListener

refname_scope_name = "constant.other.reference.link.markdown"
refname_scope_name = "entity.name.reference.link.markdown"
definition_scope_name = "meta.link.reference.def.markdown"
footnote_scope_name = "meta.link.reference.footnote.markdown"
marker_scope_name = "meta.link.reference.markdown"
marker_literal_scope_name = "meta.link.reference.literal.markdown"
marker_image_scope_name = "meta.image.reference.markdown"
footnote_scope_name = "meta.link.reference.footnote.markdown-extra"
marker_scope_name = "meta.link.reference.description.markdown"
marker_literal_scope_name = "meta.link.reference.literal.description.markdown"
marker_image_scope_name = "meta.image.reference.description.markdown"
ref_link_scope_name = "markup.underline.link.markdown"
marker_begin_scope_name = "punctuation.definition.string.begin.markdown"
marker_text_end_scope_name = "punctuation.definition.string.end.markdown"
marker_begin_scope_name = "punctuation.definition.link.begin.markdown"
marker_text_end_scope_name = "punctuation.definition.link.end.markdown"
marker_text_scope_name = "string.other.link.title.markdown"
refname_start_scope_name = "punctuation.definition.constant.begin.markdown"
marker_end_scope_name = "punctuation.definition.constant.end.markdown"
refname_start_scope_name = "punctuation.definition.metadata.begin.markdown"
marker_end_scope_name = "punctuation.definition.metadata.end.markdown"


def hasScope(scope_name, to_find):
Expand Down
5 changes: 3 additions & 2 deletions plugins/wiki_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ def contains_ref(self, filename, page_name):
link_text = PAGE_REF_FORMAT % page_name

try:
if link_text in open(filename).read():
return True
return bool(link_text in open(filename).read())
except UnicodeDecodeError:
return bool(link_text in open(filename, encoding="utf-8").read())
except OSError:
pass

Expand Down
6 changes: 0 additions & 6 deletions schemes/Mariana.sublime-color-scheme
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@
"foreground": "var(raw_fg)",
"background": "var(raw_bg)"
},
{
"name": "Inline Code Block Punctuation",
"scope": "text.html.markdown markup.raw.inline punctuation.definition.raw",
"foreground": "var(raw_bg)",
"background": "var(raw_bg)"
},
{
"name": "Raw Code Block",
"scope": "text.html.markdown markup.raw, text.html.markdown meta.code-fence",
Expand Down
6 changes: 0 additions & 6 deletions schemes/Monokai.sublime-color-scheme
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@
"foreground": "var(raw_fg)",
"background": "var(raw_bg)"
},
{
"name": "Inline Code Block Punctuation",
"scope": "text.html.markdown markup.raw.inline punctuation.definition.raw",
"foreground": "var(raw_bg)",
"background": "var(raw_bg)"
},
{
"name": "Raw Code Block",
"scope": "text.html.markdown markup.raw, text.html.markdown meta.code-fence",
Expand Down
Loading

0 comments on commit 79790ed

Please sign in to comment.