Skip to content

Commit

Permalink
fix bug: support custom css from user
Browse files Browse the repository at this point in the history
  • Loading branch information
math2001 committed Jan 22, 2017
1 parent d707cf7 commit 1bef00d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .sublime/MarkdownLivePreview.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
"caption": "MarkdownLivePreview: Clear the 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",
"command": "edit_settings",
Expand Down
8 changes: 5 additions & 3 deletions MLPApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

__folder__ = os.path.dirname(__file__)

STYLE_FILE = os.path.join(os.path.dirname(__folder__), 'User',
'MarkdownLivePreview.css')
USER_STYLE_FILE = os.path.join(os.path.dirname(__folder__), 'User', 'MarkdownLivePreview.css')

# used to store the phantom's set
windows_phantom_set = {}
Expand Down Expand Up @@ -44,7 +43,10 @@ def create_preview(window, file_name):

def get_style():
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):
global windows_phantom_set
Expand Down
8 changes: 4 additions & 4 deletions MarkdownLivePreview.tasks
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Fast:
☐ sync scroll @needsUpdate(because of images)
☐ cache image in object when used, so that it's faster @needsTest

Medium:
☐ auto refresh preview if loading images
☐ use alt attribute for 404 error
☐ fix custom css @bug

Long:
☐ support hanchor (TOC) @big
☐ support anchor (TOC) @big

Unknown:
☐ check how many times is the show_html function called


___________________
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)
✔ 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)
Expand Down
14 changes: 8 additions & 6 deletions default.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
html {
--light-bg: color(var(--background) blend(#999 85%));
--very-light-bg: color(var(--background) blend(#999 92%));
}

body {
padding:10px;
padding-top: 0px;
Expand Down Expand Up @@ -38,12 +40,12 @@ pre code {
padding-left: 0;
}

pre code .space {
color: var(--light-bg)
}

kbd {
padding: 0 .29412em;
border-radius: .2rem;
background-color: #f5f5f5;
color: #555;
box-shadow: 0 0.1rem 0 #b0b0b0;
word-break: break-word;
padding: 0 5px;
background-color: var(--very-light-bg);
font-family: "Roboto Mono","Courier New",Courier,monospace;
}
19 changes: 18 additions & 1 deletion sample.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,25 @@ Some `inline code` with *italic* and **bold** text.

```python
import this
if you('are', 'curious'):
if you is moods.curious:
print('then do it!')
```

<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)

0 comments on commit 1bef00d

Please sign in to comment.