fix loading image with relative paths
This commit is contained in:
@ -49,12 +49,10 @@ def show_html(md_view, preview):
|
|||||||
html.append(pre_with_br(md2.markdown(get_view_content(md_view),
|
html.append(pre_with_br(md2.markdown(get_view_content(md_view),
|
||||||
extras=['fenced-code-blocks',
|
extras=['fenced-code-blocks',
|
||||||
'no-code-highlighting'])))
|
'no-code-highlighting'])))
|
||||||
|
|
||||||
html = '\n'.join(html)
|
|
||||||
|
|
||||||
# the option no-code-highlighting does not exists
|
# the option no-code-highlighting does not exists
|
||||||
# in the official version of markdown2 for now
|
# in the official version of markdown2 for now
|
||||||
# I personaly edited the file (markdown2.py:1743)
|
# I personaly edited the file (markdown2.py:1743)
|
||||||
|
html = '\n'.join(html)
|
||||||
|
|
||||||
html = html.replace(' ', ' espace;') # save where are the spaces
|
html = html.replace(' ', ' espace;') # save where are the spaces
|
||||||
|
|
||||||
@ -64,7 +62,8 @@ def show_html(md_view, preview):
|
|||||||
|
|
||||||
# exception, again, because <pre> aren't supported by the phantoms
|
# exception, again, because <pre> aren't supported by the phantoms
|
||||||
html = html.replace(' espace;', '<i class="space">.</i>')
|
html = html.replace(' espace;', '<i class="space">.</i>')
|
||||||
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.erase_phantoms('markdown_preview')
|
||||||
preview.add_phantom('markdown_preview',
|
preview.add_phantom('markdown_preview',
|
||||||
sublime.Region(-1),
|
sublime.Region(-1),
|
||||||
|
|||||||
@ -4,13 +4,13 @@ Fast:
|
|||||||
☐ cache image in object when used, so that it's faster @needsTest
|
☐ cache image in object when used, so that it's faster @needsTest
|
||||||
☐ call settings listener on_new too - might be too heavy
|
☐ call settings listener on_new too - might be too heavy
|
||||||
☐ add clear cache command
|
☐ add clear cache command
|
||||||
|
☐ update README for settings in view
|
||||||
|
|
||||||
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
|
||||||
☐ use MarkdownLivePreview syntax, so we can use syntax's settings
|
☐ use MarkdownLivePreview syntax, so we can use syntax's settings
|
||||||
☐ listen for settings to change
|
☐ listen for settings to change
|
||||||
☐ fix relative source
|
|
||||||
|
|
||||||
Long:
|
Long:
|
||||||
☐ fix #4 @high
|
☐ fix #4 @high
|
||||||
@ -22,6 +22,7 @@ Unknown:
|
|||||||
|
|
||||||
___________________
|
___________________
|
||||||
Archive:
|
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)
|
✔ 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)
|
✔ 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)
|
✔ try/except for 404 @done Mon 02 Jan 2017 at 18:03 @project(Fast)
|
||||||
|
|||||||
@ -11,7 +11,7 @@ def plugin_loaded():
|
|||||||
error404 = sublime.load_resource('Packages/MarkdownLivePreview/404.txt')
|
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)"""
|
"""Really messy, but it works (should be updated)"""
|
||||||
index = -1
|
index = -1
|
||||||
tag_start = '<img src="'
|
tag_start = '<img src="'
|
||||||
@ -30,7 +30,9 @@ def replace_img_src_base64(html):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
# local image
|
# 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
|
html[index+len(tag_start):end] = image
|
||||||
shtml = ''.join(html)
|
shtml = ''.join(html)
|
||||||
return ''.join(html)
|
return ''.join(html)
|
||||||
|
|||||||
@ -13,7 +13,3 @@ if DEBUG:
|
|||||||
> Only a fool knows everything. A wise man knows how little he knows
|
> 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.
|
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.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user