From d466a29cd4f976b4387aec35e8b8dab79c4bf3ab Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Sun, 8 Jan 2017 15:30:49 +1100 Subject: [PATCH] the stylesheet's back --- MLPApi.py | 22 +++++++++++----------- default.css | 4 ---- sample.md | 14 ++++++++++---- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/MLPApi.py b/MLPApi.py index cd9d391..f09e5f5 100644 --- a/MLPApi.py +++ b/MLPApi.py @@ -6,7 +6,7 @@ import sublime_plugin import os.path from html.parser import HTMLParser -from .lib import markdown2 +from .lib import markdown2 as md2 from .escape_amp import * from .functions import * from .setting_names import * @@ -14,7 +14,7 @@ from .setting_names import * __folder__ = os.path.dirname(__file__) STYLE_FILE = os.path.join(os.path.dirname(__folder__), 'User', - 'MarkdownLivePreview.css') + 'MarkdownLivePreview.css') def plugin_loaded(): @@ -38,14 +38,17 @@ def create_preview(window, file_name): return preview def get_style(): - content = ''.join([line.strip() for line in DEFAULT_STYLE_FILE.splitlines()]) + content = ''.join([line.strip() + ' ' for line in DEFAULT_STYLE_FILE.splitlines()]) return content + "pre code .space {color: var(--light-bg)}" def show_html(md_view, preview): - html = '\n{}'.format(get_style(), - pre_with_br(markdown2.markdown(get_view_content(md_view), - extras=['fenced-code-blocks', - 'no-code-highlighting']))) + html = [] + html.append(''.format(get_style())) + html.append(pre_with_br(md2.markdown(get_view_content(md_view), + extras=['fenced-code-blocks', + 'no-code-highlighting']))) + + html = '\n'.join(html) # the option no-code-highlighting does not exists # in the official version of markdown2 for now @@ -68,11 +71,8 @@ def show_html(md_view, preview): lambda href: sublime.run_command('open_url', {'url': href})) - # set viewport position - - # sublime.set_clipboard(html) - return + # set viewport position # 0 < y < 1 y = md_view.text_to_layout(md_view.sel()[0].begin())[1] / md_view.layout_extent()[1] vector = [0, y * preview.layout_extent()[1]] diff --git a/default.css b/default.css index 66e1301..07a22fb 100644 --- a/default.css +++ b/default.css @@ -1,9 +1,5 @@ -:root, html, body { - height: 100%; -} html { --light-bg: color(var(--background) blend(#999 85%)) - height: 100%; } body { padding:10px; diff --git a/sample.md b/sample.md index f3fe174..7d21412 100644 --- a/sample.md +++ b/sample.md @@ -1,6 +1,6 @@ -# DuckDuckGo - The Search engine you'll fall in love dsfsdf +# DuckDuckGo - The Search engine you'll fall in love -This is cool +This is cool. The stylesheet's back! This is a test, and this is pretty cool! @@ -8,6 +8,12 @@ Hope you'll enjoy using MarkdownLivePreview! ![Sublime Text Forum](https://forum.sublimetext.com/uploads/st-forum-wide.png) -[GitHub](https://octodex.github.com/images/jetpacktocat.png) +```python +print(hello world) +if DEBUG: + print('DEBUG_MODE on') +``` -this is a test +> Only a fool knows everything. A wise man knows how little he knows + +The only think I know right now is that Boxy Theme's just awesome.