Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 05c471b5d9 | |||
| 76f580ba29 |
@ -73,8 +73,7 @@ def markdown2html(md, basepath, color_scheme):
|
|||||||
|
|
||||||
def show_html(md_view, preview):
|
def show_html(md_view, preview):
|
||||||
global windows_phantom_set
|
global windows_phantom_set
|
||||||
html = markdown2html(get_view_content(md_view), os.path.dirname(md_view.file_name()),
|
html = markdown2html(get_view_content(md_view), os.path.dirname(md_view.file_name()), md_view.settings().get('color_scheme'))
|
||||||
os.path.join(sublime.packages_path(), '..', md_view.settings().get('color_scheme')))
|
|
||||||
|
|
||||||
phantom_set = windows_phantom_set.setdefault(preview.window().id(),
|
phantom_set = windows_phantom_set.setdefault(preview.window().id(),
|
||||||
sublime.PhantomSet(preview, 'markdown_live_preview'))
|
sublime.PhantomSet(preview, 'markdown_live_preview'))
|
||||||
|
|||||||
@ -128,5 +128,12 @@ def get_style(color_scheme):
|
|||||||
with open(USER_STYLE_FILE) as fp:
|
with open(USER_STYLE_FILE) as fp:
|
||||||
css += '\n' + fp.read() + '\n'
|
css += '\n' + fp.read() + '\n'
|
||||||
if color_scheme:
|
if color_scheme:
|
||||||
css += pygments_from_theme(color_scheme)
|
css += pygments_from_theme(get_resource(color_scheme))
|
||||||
return ''.join([line.strip() + ' ' for line in css.splitlines()])
|
return ''.join([line.strip() + ' ' for line in css.splitlines()])
|
||||||
|
|
||||||
|
def get_resource(resource):
|
||||||
|
if os.path.exists(os.path.join(sublime.packages_path(), '..', resource)):
|
||||||
|
with open(resource) as fp:
|
||||||
|
return fp.read()
|
||||||
|
else:
|
||||||
|
return sublime.load_resource(resource)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from xml.dom.minidom import parse
|
from xml.dom.minidom import parseString
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
class Style:
|
class Style:
|
||||||
@ -55,9 +55,9 @@ class Style:
|
|||||||
# colors and font styles from colortheme file
|
# colors and font styles from colortheme file
|
||||||
|
|
||||||
|
|
||||||
def get_settings(file_name):
|
def get_settings(color_scheme_content):
|
||||||
settings = defaultdict(lambda: [])
|
settings = defaultdict(lambda: [])
|
||||||
dom = parse(file_name)
|
dom = parseString(color_scheme_content)
|
||||||
arr = dom.getElementsByTagName('array')[0]
|
arr = dom.getElementsByTagName('array')[0]
|
||||||
editor_cfg = arr.getElementsByTagName('dict')[0].getElementsByTagName('dict')[0]
|
editor_cfg = arr.getElementsByTagName('dict')[0].getElementsByTagName('dict')[0]
|
||||||
editor_vals = editor_cfg.getElementsByTagName('string')
|
editor_vals = editor_cfg.getElementsByTagName('string')
|
||||||
@ -82,8 +82,8 @@ def get_settings(file_name):
|
|||||||
return settings
|
return settings
|
||||||
|
|
||||||
|
|
||||||
def pygments_from_theme(file):
|
def pygments_from_theme(color_scheme_content):
|
||||||
settings = get_settings(file)
|
settings = get_settings(color_scheme_content)
|
||||||
styles = []
|
styles = []
|
||||||
|
|
||||||
#Generic
|
#Generic
|
||||||
|
|||||||
Reference in New Issue
Block a user