Local image loading now working. #19

This commit is contained in:
Mathieu PATUREL
2017-02-18 08:13:45 +11:00
parent b93aea6698
commit 7c4354fb2e
4 changed files with 5 additions and 12 deletions

View File

@ -33,7 +33,8 @@ def create_preview(window, file_name):
return preview return preview
def markdown2html(md, basepath, color_scheme): def markdown2html(md, basepath, color_scheme):
# removes/format the header.
# removes/format the YAML/TOML header.
md = manage_header(md, get_settings().get('header_action')) md = manage_header(md, get_settings().get('header_action'))
html = '<style>\n{}\n</style>\n'.format(get_style(color_scheme)) html = '<style>\n{}\n</style>\n'.format(get_style(color_scheme))
@ -63,7 +64,7 @@ def markdown2html(md, basepath, color_scheme):
# Phantoms have problem with images size when they're loaded from an url/path # Phantoms have problem with images size when they're loaded from an url/path
# So, the solution is to convert them to base64 # So, the solution is to convert them to base64
html = replace_img_src_base64(html, basepath=os.path.dirname(basepath)) html = replace_img_src_base64(html, basepath=basepath)
# BeautifulSoup uses the <br/> but the sublime phantoms do not support them... # BeautifulSoup uses the <br/> but the sublime phantoms do not support them...
html = html.replace('<br/>', '<br />').replace('<hr/>', '<hr />') html = html.replace('<br/>', '<br />').replace('<hr/>', '<hr />')

View File

@ -14,7 +14,6 @@ def plugin_loaded():
DEFAULT_STYLE = sublime.load_resource('Packages/MarkdownLivePreview/default.css') DEFAULT_STYLE = sublime.load_resource('Packages/MarkdownLivePreview/default.css')
USER_STYLE_FILE = os.path.join(sublime.packages_path(), 'User', "MarkdownLivePreview.css") USER_STYLE_FILE = os.path.join(sublime.packages_path(), 'User', "MarkdownLivePreview.css")
print(USER_STYLE_FILE)
MATCH_YAML_HEADER = re.compile(r'^([\-\+])\1{2}\n(?P<content>.+)\n\1{3}\n', re.DOTALL) MATCH_YAML_HEADER = re.compile(r'^([\-\+])\1{2}\n(?P<content>.+)\n\1{3}\n', re.DOTALL)

View File

@ -1,9 +0,0 @@
Hello world
```python
print('Hello world')
if hello:
print('hello')
for i in range(4):
print(i)
```

View File

@ -8,3 +8,5 @@ if you.are('new'):
else: else:
print('Hello!') print('Hello!')
``` ```
![img](docs/imgs/syntax-specific-settings.png)