diff --git a/MLPApi.py b/MLPApi.py index d1a6c99..a0bec98 100644 --- a/MLPApi.py +++ b/MLPApi.py @@ -49,12 +49,10 @@ def show_html(md_view, preview): html.append(pre_with_br(md2.markdown(get_view_content(md_view), extras=['fenced-code-blocks', 'no-code-highlighting']))) - - html = '\n'.join(html) - # the option no-code-highlighting does not exists # in the official version of markdown2 for now # I personaly edited the file (markdown2.py:1743) + html = '\n'.join(html) html = html.replace(' ', ' espace;') # save where are the spaces @@ -64,7 +62,8 @@ def show_html(md_view, preview): # exception, again, because
aren't supported by the phantoms
html = html.replace(' espace;', '.')
- html = replace_img_src_base64(html)
+ html = replace_img_src_base64(html, basepath=os.path.dirname(
+ md_view.file_name()))
preview.erase_phantoms('markdown_preview')
preview.add_phantom('markdown_preview',
sublime.Region(-1),
diff --git a/MarkdownLivePreview.tasks b/MarkdownLivePreview.tasks
index fb6c7b7..3918bba 100644
--- a/MarkdownLivePreview.tasks
+++ b/MarkdownLivePreview.tasks
@@ -4,13 +4,13 @@ Fast:
☐ cache image in object when used, so that it's faster @needsTest
☐ call settings listener on_new too - might be too heavy
☐ add clear cache command
+ ☐ update README for settings in view
Medium:
☐ auto refresh preview if loading images
☐ use alt attribute for 404 error
☐ use MarkdownLivePreview syntax, so we can use syntax's settings
☐ listen for settings to change
- ☐ fix relative source
Long:
☐ fix #4 @high
@@ -22,6 +22,7 @@ Unknown:
___________________
Archive:
+ ✔ fix relative source @done Sun 08 Jan 2017 at 19:22 @project(Medium)
✔ add settings for the preview @done Sun 08 Jan 2017 at 17:36 @project(Fast)
✔ regive focus to the right markdown view @done Mon 02 Jan 2017 at 18:34 @project(Fast)
✔ try/except for 404 @done Mon 02 Jan 2017 at 18:03 @project(Fast)
diff --git a/functions.py b/functions.py
index 04490be..c22b79d 100644
--- a/functions.py
+++ b/functions.py
@@ -11,7 +11,7 @@ def plugin_loaded():
error404 = sublime.load_resource('Packages/MarkdownLivePreview/404.txt')
-def replace_img_src_base64(html):
+def replace_img_src_base64(html, basepath):
"""Really messy, but it works (should be updated)"""
index = -1
tag_start = ':
else:
# local image
- image = to_base64(''.join(path))
+ path = ''.join(path)
+ path = os.path.join(basepath, path)
+ image = to_base64(path)
html[index+len(tag_start):end] = image
shtml = ''.join(html)
return ''.join(html)
diff --git a/sample.md b/sample.md
index d13d719..4ed3dac 100644
--- a/sample.md
+++ b/sample.md
@@ -13,7 +13,3 @@ if DEBUG:
> Only a fool knows everything. A wise man knows how little he knows
The only think I know right now is that Boxy Theme's just awesome.
-
-this is a test, hello world, I know this, it's cool
-
-Hello world, this is a test, and it's working also.
)