add option: keep the md view when previewing #13

Keep the markdown view opened in the original window when when opening
the preview
This commit is contained in:
Mathieu PATUREL
2017-01-27 09:55:52 +11:00
parent 52e4b917e5
commit 30d75f159d
4 changed files with 12 additions and 6 deletions

View File

@ -1,4 +1,12 @@
{ {
// As soon as you open a markdown file, it opens the window preview
"markdown_live_preview_on_open": false, "markdown_live_preview_on_open": false,
"load_from_internet_when_starts": ["http://", "https://"]
// If an image starts with one of those strings, then it will be loaded from internet
"load_from_internet_when_starts": ["http://", "https://"],
// When the preview is opened, the markdown file is closed in the origin window and reopend in
// the preview window. If this option is set to 'true', then the markdown file will NOT be
// closed in the origin window
"keep_open_when_opening_preview": false
} }

View File

@ -15,6 +15,7 @@ class NewMarkdownLivePreviewCommand(sublime_plugin.ApplicationCommand):
current_view = sublime.active_window().active_view() current_view = sublime.active_window().active_view()
file_name = current_view.file_name() file_name = current_view.file_name()
if get_settings().get('keep_open_when_opening_preview') is False:
current_view.close() current_view.close()
if file_name is None: if file_name is None:
return sublime.error_message('MarkdownLivePreview: Not supporting ' return sublime.error_message('MarkdownLivePreview: Not supporting '

View File

@ -26,9 +26,6 @@ def get_preview_name(md_view):
return name + ' - Preview' return name + ' - Preview'
def replace_img_src_base64(html, basepath): def replace_img_src_base64(html, basepath):
"""Really messy, but it works (should be updated)"""
soup = BeautifulSoup(html) soup = BeautifulSoup(html)
load_from_internet_starters = get_settings().get('load_from_internet_when_starts') load_from_internet_starters = get_settings().get('load_from_internet_when_starts')
for img in soup.find_all('img'): for img in soup.find_all('img'):

View File

@ -2,7 +2,7 @@
<!-- supports comments --> <!-- supports comments -->
And `<!-- vicious onces -->` And `<!-- vicious ones ;) -->`
Some `inline code` with *italic* and **bold** text. Some `inline code` with *italic* and **bold** text.