fix bug: support custom css from user

This commit is contained in:
Mathieu PATUREL
2017-01-22 18:41:36 +11:00
parent d707cf7a47
commit 1bef00de14
5 changed files with 42 additions and 14 deletions

View File

@ -7,6 +7,13 @@
"caption": "MarkdownLivePreview: Clear the cache", "caption": "MarkdownLivePreview: Clear the cache",
"command": "markdown_live_preview_clear_cache" "command": "markdown_live_preview_clear_cache"
}, },
{
"caption": "MarkdownLivePreview: Edit Custom CSS File",
"command": "open_file",
"args": {
"file": "$packages/User/MarkdownLivePreview.css"
}
},
{ {
"caption": "Preferences: MarkdownLivePreview Settings", "caption": "Preferences: MarkdownLivePreview Settings",
"command": "edit_settings", "command": "edit_settings",

View File

@ -15,8 +15,7 @@ from random import randint as rnd
__folder__ = os.path.dirname(__file__) __folder__ = os.path.dirname(__file__)
STYLE_FILE = os.path.join(os.path.dirname(__folder__), 'User', USER_STYLE_FILE = os.path.join(os.path.dirname(__folder__), 'User', 'MarkdownLivePreview.css')
'MarkdownLivePreview.css')
# used to store the phantom's set # used to store the phantom's set
windows_phantom_set = {} windows_phantom_set = {}
@ -44,7 +43,10 @@ def create_preview(window, file_name):
def get_style(): 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)}" if os.path.exists(USER_STYLE_FILE):
with open(USER_STYLE_FILE) as fp:
content += '\n' + fp.read() + '\n'
return content
def show_html(md_view, preview): def show_html(md_view, preview):
global windows_phantom_set global windows_phantom_set

View File

@ -1,21 +1,21 @@
Fast: Fast:
☐ sync scroll @needsUpdate(because of images)
☐ cache image in object when used, so that it's faster @needsTest ☐ cache image in object when used, so that it's faster @needsTest
Medium: Medium:
☐ auto refresh preview if loading images ☐ auto refresh preview if loading images
☐ use alt attribute for 404 error ☐ use alt attribute for 404 error
☐ fix custom css @bug
Long: Long:
☐ support hanchor (TOC) @big ☐ support anchor (TOC) @big
Unknown: Unknown:
☐ check how many times is the show_html function called
___________________ ___________________
Archive: Archive:
✔ fix custom css @bug @done Sun 22 Jan 2017 at 18:40 @project(Medium)
✘ check how many times is the show_html function called @cancelled Sun 22 Jan 2017 at 18:40 @project(Unknown)
✔ sync scroll @needsUpdate(because of images) @done Sun 22 Jan 2017 at 18:39 @project(Fast)
✔ fix #4 @high @done Mon 09 Jan 2017 at 18:42 @project(Long) ✔ fix #4 @high @done Mon 09 Jan 2017 at 18:42 @project(Long)
✔ use MarkdownLivePreview syntax, so we can use syntax's settings @done Mon 09 Jan 2017 at 18:41 @project(Medium) ✔ use MarkdownLivePreview syntax, so we can use syntax's settings @done Mon 09 Jan 2017 at 18:41 @project(Medium)
✔ add clear cache command @done Mon 09 Jan 2017 at 18:41 @project(Fast) ✔ add clear cache command @done Mon 09 Jan 2017 at 18:41 @project(Fast)

View File

@ -1,6 +1,8 @@
html { html {
--light-bg: color(var(--background) blend(#999 85%)); --light-bg: color(var(--background) blend(#999 85%));
--very-light-bg: color(var(--background) blend(#999 92%));
} }
body { body {
padding:10px; padding:10px;
padding-top: 0px; padding-top: 0px;
@ -38,12 +40,12 @@ pre code {
padding-left: 0; padding-left: 0;
} }
pre code .space {
color: var(--light-bg)
}
kbd { kbd {
padding: 0 .29412em; padding: 0 5px;
border-radius: .2rem; background-color: var(--very-light-bg);
background-color: #f5f5f5;
color: #555;
box-shadow: 0 0.1rem 0 #b0b0b0;
word-break: break-word;
font-family: "Roboto Mono","Courier New",Courier,monospace; font-family: "Roboto Mono","Courier New",Courier,monospace;
} }

View File

@ -4,8 +4,25 @@ Some `inline code` with *italic* and **bold** text.
```python ```python
import this import this
if you('are', 'curious'): if you is moods.curious:
print('then do it!') print('then do it!')
``` ```
<kbd>ctrl+\`</kbd> or *View → Show Console* and paste `import this`! <kbd>ctrl+\`</kbd> or *View → Show Console* and paste `import this`!
> Perfect programmers do NOT need comments.
- to be efficient
- you need
- todos
![Sublime Text Logo](https://upload.wikimedia.org/wikipedia/en/4/4c/Sublime_Text_Logo.png)
Some plugin I just *need*:
- [PackageResourceReviewer](https://packagecontrol.io/packages/PackageResourceViewer)
- [Boxy Theme](https://packagecontrol.io/packages/Boxy%20Theme)
- [Markdown Preview](https://packagecontrol.io/packages/Markdown%20Preview)
- [FileManager](https://packagecontrol.io/packages/FileManager)
- [PlainTasks](https://packagecontrol.io/packages/PlainTasks)
- [JSONComma](https://packagecontrol.io/packages/JSONComma)