From 4b1bc0d8bc192075646bc65e0d56d0d0b5e611f9 Mon Sep 17 00:00:00 2001 From: math2001 Date: Sat, 26 Nov 2016 11:10:21 +1100 Subject: [PATCH] custom css feature @done --- Main.sublime-menu | 20 ++++++++++++++++++++ README.md | 2 ++ md_in_popup.py | 6 ++++-- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 Main.sublime-menu diff --git a/Main.sublime-menu b/Main.sublime-menu new file mode 100644 index 0000000..efaa3a9 --- /dev/null +++ b/Main.sublime-menu @@ -0,0 +1,20 @@ +[ + { + "id": "preferences", + "children": [ + { + "id": "package-settings", + "children": [ + { + "caption": "MarkdownLivePreview", + "command": "open_file", + "args": { + "file": "$packages/User/MarkdownLivePreview.css", + "contents": "/* See http://www.sublimetext.com/docs/3/minihtml.html#css to know which property you're able to use */\n\n$0" + } + } + ] + } + ] + } +] diff --git a/README.md b/README.md index 0433333..0729496 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ This plugin is not finished, there's still some things to fix (custom css, focus ### Custom css +It is possible to set your own css. But, be carefull, you have to respect [those rules](http://www.sublimetext.com/docs/3/minihtml.html#css). Just go to `Preferences -> Package Settings -> MarkdownLivePreview`. It will open a css file, here: `$packages/User/MarkdownLivePreview.css`. Just save it and it will automatically use it instead of the default one. + ### How to open the [README](http://github.com/math2001/MarkdownLivePreview/README.md) Some of the package add a command in the menus, others in the command palette, or other nowhere. None of those options are really good, especially the last one on ST3 because the packages are compressed. But, fortunately, there is plugin that exists and **will solve this problem** for us (and he has a really cute name, don't you think?): [ReadmePlease](https://packagecontrol.io/packages/ReadmePlease). diff --git a/md_in_popup.py b/md_in_popup.py index 3021ea0..eecebae 100644 --- a/md_in_popup.py +++ b/md_in_popup.py @@ -27,7 +27,9 @@ def get_style(): """Of course, this is temporal, there will be an option to customize the CSS""" if os.path.exists(STYLE_FILE): with open(STYLE_FILE) as fp: - return fp.read() + content = fp.read() + if content: + return content return """ body { @@ -63,7 +65,7 @@ def get_style(): pre code { padding-left: 0; } - """.replace('\n', '').replace('\t', '') + """ def pre_with_br(html): """Because the phantoms of sublime text does not support
 blocks