Skip to content

Commit

Permalink
Merge pull request #627 from SublimeText-Markdown/3.0.2
Browse files Browse the repository at this point in the history
# MarkdownEditing 3.0.2 Changelog

## Bug Fixes

* Add missing Automatic Link Folding usage description
* Improve bootstrapper (fixes #623)
* Correct heading style detection (fixes #625)
* Correct wiki link selectors (fixes #626)
* Strip image/ref urls from indexed symbols
  • Loading branch information
deathaxe authored Sep 14, 2021
2 parents 5501a66 + 8a1ba62 commit 1cc6d7d
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 35 deletions.
4 changes: 2 additions & 2 deletions Default (Linux).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -1168,13 +1168,13 @@
},
{ "keys": ["ctrl+alt+d"], "command": "mde_open_page", "context":
[
{ "key": "selector", "operator": "equal", "operand": "meta.link.wiki.markdown", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "meta.link.reference.wiki.markdown", "match_all": true },
{ "key": "setting.mde.keymap_disable.open_page", "operator": "not_equal", "operand": true }
]
},
{ "keys": ["ctrl+alt+d"], "command": "mde_make_page_reference", "context":
[
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown - (meta.link.wiki | markup.underline.link)", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown - (meta.link | markup.underline.link)", "match_all": true },
{ "key": "setting.mde.keymap_disable.make_page_reference", "operator": "not_equal", "operand": true }
]
},
Expand Down
4 changes: 2 additions & 2 deletions Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -1168,13 +1168,13 @@
},
{ "keys": ["super+shift+d"], "command": "mde_open_page", "context":
[
{ "key": "selector", "operator": "equal", "operand": "meta.link.wiki.markdown", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "meta.link.reference.wiki.markdown", "match_all": true },
{ "key": "setting.mde.keymap_disable.open_page", "operator": "not_equal", "operand": true }
]
},
{ "keys": ["super+shift+d"], "command": "mde_make_page_reference", "context":
[
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown - (meta.link.wiki | markup.underline.link)", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown - (meta.link | markup.underline.link)", "match_all": true },
{ "key": "setting.mde.keymap_disable.make_page_reference", "operator": "not_equal", "operand": true }
]
},
Expand Down
4 changes: 2 additions & 2 deletions Default (Windows).sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -1168,13 +1168,13 @@
},
{ "keys": ["ctrl+alt+d"], "command": "mde_open_page", "context":
[
{ "key": "selector", "operator": "equal", "operand": "meta.link.wiki.markdown", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "meta.link.reference.wiki.markdown", "match_all": true },
{ "key": "setting.mde.keymap_disable.open_page", "operator": "not_equal", "operand": true }
]
},
{ "keys": ["ctrl+alt+d"], "command": "mde_make_page_reference", "context":
[
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown - (meta.link.wiki | markup.underline.link)", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown - (meta.link | markup.underline.link)", "match_all": true },
{ "key": "setting.mde.keymap_disable.make_page_reference", "operator": "not_equal", "operand": true }
]
},
Expand Down
2 changes: 1 addition & 1 deletion Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"command": "mde_unfold_all_sections"
},
{
"caption": "MarkdownEditing: Auto Fold Link URLs",
"caption": "MarkdownEditing: Toggle Automatic Link URL Folding",
"command": "mde_fold_links"
},

Expand Down
20 changes: 20 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,26 @@ Folding is bound to following keys by default:
| <kbd>Shift</kbd> + <kbd>Tab</kbd> | <kbd>⇧</kbd> + <kbd>Tab</kbd> | Fold/Unfold current section.
| <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Tab</kbd> | <kbd>^</kbd> + <kbd>⇧</kbd> + <kbd>Tab</kbd> | Fold all sections under headings of a certain level.
## Automatic Link Url Folding
MarkdownEditing folds image/link/reference urls automatically if the caret is not within the url brackets, in order to improve a document's readability.
This feature can be temporarily enabled or disabled for the active view via Command Palette
* **MarkdownEditing: Toggle Automatic Link URL Folding**
To globally disable it, add the following setting to _Perferences.sublime-settings_
```jsonc
"mde.auto_fold_link.enabled": false,
```

The folding selector can be tweaked in order to add or remove certain kinds of urls from being automatically folded.

```jsonc
"mde.auto_fold_link.selector": "( meta.image | meta.link ) & ( markup.underline | constant.other) - meta.link.reference.footnote - meta.link.reference.def - meta.link.inet",
```

## Navigation

MarkdownEditing provides various ways to navigate between sections.
Expand Down
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"2.2.4": "messages/2.2.4.md",
"2.2.10": "messages/2.2.10.md",
"3.0.0": "messages/3.0.0.md",
"3.0.1": "messages/3.0.1.md"
"3.0.1": "messages/3.0.1.md",
"3.0.1": "messages/3.0.2.md"
}
14 changes: 14 additions & 0 deletions messages/3.0.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# MarkdownEditing 3.0.2 Changelog

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

## Bug Fixes

* Add missing Automatic Link Folding usage description
* Improve bootstrapper (fixes #623)
* Correct heading style detection (fixes #625)
* Correct wiki link selectors (fixes #626)
* Strip image/ref urls from indexed symbols

[issues]: https://github.com/SublimeText-Markdown/MarkdownEditing/issues
33 changes: 25 additions & 8 deletions plugins/bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os
import shutil
import sys

import sublime

from .color_schemes import clear_color_schemes, select_color_scheme

BOOTSTRAP_VERSION = 3.0
BOOTSTRAP_VERSION = "3.0.2"

package_name = "MarkdownEditing"

Expand Down Expand Up @@ -63,18 +65,33 @@ def reassign_syntax(current_syntax, new_syntax):


def on_after_install():
mde_settings = sublime.load_settings("MarkdownEditing.sublime-syntax")
bootstrapped = mde_settings.get("bootstrapped")
if bootstrapped is not None and bootstrapped == BOOTSTRAP_VERSION:
return
cache_path = os.path.join(sublime.cache_path(), "MarkdownEditing")
bootstrapped = os.path.join(cache_path, "bootstrapped")

# Check bootstrapped cookie.
try:
if open(bootstrapped).read() == BOOTSTRAP_VERSION:
return
except FileNotFoundError:
pass

# Clear previous syntax caches.
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

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

mde_settings.set("bootstrapped", BOOTSTRAP_VERSION)
sublime.save_settings("MarkdownEditing.sublime-syntax")
# Update bootstrap cookie.
open(bootstrapped, "w").write(BOOTSTRAP_VERSION)


def on_before_uninstall():
Expand Down
19 changes: 8 additions & 11 deletions plugins/headings/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,16 @@ def auto_detect_heading_style(self):
view.settings().set("mde.auto_match_heading_hashes", False)
return

num_leading = 0
num_trailing = 0

for h1, h2 in zip(
view.find_by_selector("markup.heading")[:10],
view.find_by_selector("markup.heading - punctuation.definition.heading")[:10],
):
num_leading += 1
if h1.end() > h2.end():
num_trailing += 1

num_leading = len(
view.find_by_selector("markup.heading punctuation.definition.heading.begin")
)
if num_leading:
num_trailing = len(
view.find_by_selector("markup.heading punctuation.definition.heading.end")
)
view.settings().set("mde.match_heading_hashes", num_trailing / num_leading > 0.5)
else:
view.settings().erase("mde.match_heading_hashes")

if view.settings().get("mde.auto_match_heading_hashes", False):
view.run_command("mde_match_heading_hashes")
8 changes: 4 additions & 4 deletions plugins/wiki_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MdeMakePageReferenceCommand(MdeTextCommand):
def is_visible(self):
"""Return True if is on a wiki page reference."""
for sel in self.view.sel():
if not self.view.match_selector(sel.end(), "meta.link.wiki.markdown"):
if self.view.match_selector(sel.begin(), "meta.link.reference.wiki"):
return False
return True

Expand Down Expand Up @@ -66,9 +66,9 @@ class MdeOpenPageCommand(MdeTextCommand):
def is_visible(self):
"""Return True if caret is on a wiki page reference."""
for sel in self.view.sel():
if not self.view.match_selector(sel.end(), "meta.link.wiki.markdown"):
return False
return True
if self.view.match_selector(sel.begin(), "meta.link.reference.wiki"):
return True
return False

def run(self, edit):
wiki_page = WikiPage(self.view)
Expand Down
11 changes: 7 additions & 4 deletions syntaxes/Symbol List - Heading.tmPreferences
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<key>showInSymbolList</key>
<integer>1</integer>
<key>symbolTransformation</key>
<string>
<string><![CDATA[
s/\!?\[([^]]+)\]\([^)]*\)/$1/g; # strip image or link urls
s/\[([^]]+)\]\[[^]]*\]/$1/g; # strip reference urls
s/\[\^[^]]+\]//g; # strip footnotes
Expand All @@ -20,14 +20,17 @@
s/^#{3}/ /g; # indent atx heading
s/^#{2}/ /g; # indent atx heading
s/^#{1}//g; # indent atx heading
</string>
]]></string>
<key>showInIndexedSymbolList</key>
<integer>1</integer>
<key>symbolIndexTransformation</key>
<string>
<string><![CDATA[
s/\!?\[([^]]+)\]\([^)]*\)/$1/g; # strip image or link urls
s/\[([^]]+)\]\[[^]]*\]/$1/g; # strip reference urls
s/\[\^[^]]+\]//g; # strip footnotes
s/^\s*//g; # strip leading whitespace
s/\s*#+\s*\z//g; # strip trailing hashes
</string>
]]></string>
</dict>
</dict>
</plist>

0 comments on commit 1cc6d7d

Please sign in to comment.