From 30d75f159dd0604c33c07a90d72817e334113ff7 Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Fri, 27 Jan 2017 09:55:52 +1100 Subject: [PATCH] add option: keep the md view when previewing #13 Keep the markdown view opened in the original window when when opening the preview --- .sublime/MarkdownLivePreview.sublime-settings | 10 +++++++++- MarkdownLivePreview.py | 3 ++- functions.py | 3 --- sample.md | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.sublime/MarkdownLivePreview.sublime-settings b/.sublime/MarkdownLivePreview.sublime-settings index 6ee0e56..3b57d3b 100644 --- a/.sublime/MarkdownLivePreview.sublime-settings +++ b/.sublime/MarkdownLivePreview.sublime-settings @@ -1,4 +1,12 @@ { + // As soon as you open a markdown file, it opens the window preview "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 } diff --git a/MarkdownLivePreview.py b/MarkdownLivePreview.py index 5f377bb..6c7b86f 100644 --- a/MarkdownLivePreview.py +++ b/MarkdownLivePreview.py @@ -15,7 +15,8 @@ class NewMarkdownLivePreviewCommand(sublime_plugin.ApplicationCommand): current_view = sublime.active_window().active_view() file_name = current_view.file_name() - current_view.close() + if get_settings().get('keep_open_when_opening_preview') is False: + current_view.close() if file_name is None: return sublime.error_message('MarkdownLivePreview: Not supporting ' 'unsaved file for now') diff --git a/functions.py b/functions.py index 534cacc..cd10688 100644 --- a/functions.py +++ b/functions.py @@ -26,9 +26,6 @@ def get_preview_name(md_view): return name + ' - Preview' def replace_img_src_base64(html, basepath): - """Really messy, but it works (should be updated)""" - - soup = BeautifulSoup(html) load_from_internet_starters = get_settings().get('load_from_internet_when_starts') for img in soup.find_all('img'): diff --git a/sample.md b/sample.md index 9a5c5fe..ae68b3d 100644 --- a/sample.md +++ b/sample.md @@ -2,7 +2,7 @@ -And `` +And `` Some `inline code` with *italic* and **bold** text.