Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4198504fd1 | |||
| 1bef00de14 | |||
| d707cf7a47 | |||
| c27cd5f210 | |||
| 41bbc3d03d | |||
| 1e651bebc6 | |||
| ea309f2323 | |||
| 3306d6ad5e | |||
| 0505ca30bc | |||
| c49ae26720 | |||
| c2618ead1d | |||
| 6e113fef6e | |||
| e5378e2300 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
Thumbs.db
|
Thumbs.db
|
||||||
__pycache__/
|
__pycache__/
|
||||||
cache.txt
|
cache.txt
|
||||||
|
venv/
|
||||||
|
site/
|
||||||
|
|||||||
@ -23,11 +23,11 @@
|
|||||||
"file": "$packages/User/MarkdownLivePreview.css",
|
"file": "$packages/User/MarkdownLivePreview.css",
|
||||||
"contents": "/* See http://www.sublimetext.com/docs/3/minihtml.html#css to know which property you're able to use */\n\n$0"
|
"contents": "/* See http://www.sublimetext.com/docs/3/minihtml.html#css to know which property you're able to use */\n\n$0"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -4,9 +4,16 @@
|
|||||||
"command": "new_markdown_live_preview"
|
"command": "new_markdown_live_preview"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"caption": "MarkdownLivePreview: Clear Cache",
|
"caption": "MarkdownLivePreview: Clear the cache",
|
||||||
"command": "markdown_live_preview_clear_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",
|
"caption": "Preferences: MarkdownLivePreview Settings",
|
||||||
"command": "edit_settings",
|
"command": "edit_settings",
|
||||||
|
|||||||
7
LICENSE
Normal file
7
LICENSE
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Copyright 2017 Mathieu PATUREL
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
39
MLPApi.py
39
MLPApi.py
@ -11,17 +11,18 @@ from .escape_amp import *
|
|||||||
from .functions import *
|
from .functions import *
|
||||||
from .setting_names import *
|
from .setting_names import *
|
||||||
from .image_manager import CACHE_FILE
|
from .image_manager import CACHE_FILE
|
||||||
|
from random import randint as rnd
|
||||||
|
|
||||||
__folder__ = os.path.dirname(__file__)
|
__folder__ = os.path.dirname(__file__)
|
||||||
|
|
||||||
STYLE_FILE = os.path.join(os.path.dirname(__folder__), 'User',
|
USER_STYLE_FILE = os.path.join(os.path.dirname(__folder__), 'User', 'MarkdownLivePreview.css')
|
||||||
'MarkdownLivePreview.css')
|
|
||||||
|
|
||||||
|
# used to store the phantom's set
|
||||||
|
windows_phantom_set = {}
|
||||||
|
|
||||||
def plugin_loaded():
|
def plugin_loaded():
|
||||||
global DEFAULT_STYLE_FILE
|
global DEFAULT_STYLE_FILE
|
||||||
DEFAULT_STYLE_FILE = sublime.load_resource('Packages/MarkdownLivePreview/'
|
DEFAULT_STYLE_FILE = sublime.load_resource('Packages/MarkdownLivePreview/default.css')
|
||||||
'default.css')
|
|
||||||
|
|
||||||
def get_preview_name(md_view):
|
def get_preview_name(md_view):
|
||||||
file_name = md_view.file_name()
|
file_name = md_view.file_name()
|
||||||
@ -35,16 +36,20 @@ def create_preview(window, file_name):
|
|||||||
|
|
||||||
preview.set_name(get_preview_name(file_name))
|
preview.set_name(get_preview_name(file_name))
|
||||||
preview.set_scratch(True)
|
preview.set_scratch(True)
|
||||||
preview.set_syntax_file('Packages/MarkdownLivePreview/.sublime/'
|
preview.set_syntax_file('Packages/MarkdownLivePreview/.sublime/' + \
|
||||||
'MarkdownLivePreviewSyntax.hidden-tmLanguage')
|
'MarkdownLivePreviewSyntax.hidden-tmLanguage')
|
||||||
|
|
||||||
return preview
|
return preview
|
||||||
|
|
||||||
def get_style():
|
def get_style():
|
||||||
content = ''.join([line.strip() + ' ' for line in DEFAULT_STYLE_FILE.splitlines()])
|
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):
|
def show_html(md_view, preview):
|
||||||
|
global windows_phantom_set
|
||||||
html = []
|
html = []
|
||||||
html.append('<style>\n{}\n</style>'.format(get_style()))
|
html.append('<style>\n{}\n</style>'.format(get_style()))
|
||||||
html.append(pre_with_br(md2.markdown(get_view_content(md_view),
|
html.append(pre_with_br(md2.markdown(get_view_content(md_view),
|
||||||
@ -65,14 +70,15 @@ def show_html(md_view, preview):
|
|||||||
html = html.replace(' espace;', '<i class="space">.</i>')
|
html = html.replace(' espace;', '<i class="space">.</i>')
|
||||||
html = replace_img_src_base64(html, basepath=os.path.dirname(
|
html = replace_img_src_base64(html, basepath=os.path.dirname(
|
||||||
md_view.file_name()))
|
md_view.file_name()))
|
||||||
preview.erase_phantoms('markdown_preview')
|
|
||||||
preview.add_phantom('markdown_preview',
|
|
||||||
sublime.Region(-1),
|
|
||||||
html,
|
|
||||||
sublime.LAYOUT_BLOCK,
|
|
||||||
lambda href: sublime.run_command('open_url',
|
|
||||||
{'url': href}))
|
|
||||||
|
|
||||||
|
phantom_set = windows_phantom_set.setdefault(preview.window().id(),
|
||||||
|
sublime.PhantomSet(preview,
|
||||||
|
'markdown_live_preview'))
|
||||||
|
phantom_set.update([sublime.Phantom(sublime.Region(0), html, sublime.LAYOUT_BLOCK,
|
||||||
|
lambda href: sublime.run_command('open_url',
|
||||||
|
{'url': href}))])
|
||||||
|
|
||||||
|
# lambda href: sublime.run_command('open_url', {'url': href})
|
||||||
# get the "ratio" of the markdown view's position.
|
# get the "ratio" of the markdown view's position.
|
||||||
# 0 < y < 1
|
# 0 < y < 1
|
||||||
y = md_view.text_to_layout(md_view.sel()[0].begin())[1] / md_view.layout_extent()[1]
|
y = md_view.text_to_layout(md_view.sel()[0].begin())[1] / md_view.layout_extent()[1]
|
||||||
@ -89,3 +95,10 @@ def show_html(md_view, preview):
|
|||||||
def clear_cache():
|
def clear_cache():
|
||||||
"""Removes the cache file"""
|
"""Removes the cache file"""
|
||||||
os.remove(CACHE_FILE)
|
os.remove(CACHE_FILE)
|
||||||
|
|
||||||
|
def release_phantoms_set(view_id=None):
|
||||||
|
global windows_phantom_set
|
||||||
|
if view_id is None:
|
||||||
|
windows_phantom_set = {}
|
||||||
|
else:
|
||||||
|
del windows_phantom_set[view_id]
|
||||||
|
|||||||
@ -64,6 +64,7 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener):
|
|||||||
|
|
||||||
def on_window_command(self, window, command, args):
|
def on_window_command(self, window, command, args):
|
||||||
if command == 'close' and window.settings().get(PREVIEW_WINDOW):
|
if command == 'close' and window.settings().get(PREVIEW_WINDOW):
|
||||||
|
release_phantoms_set(window.id())
|
||||||
return 'close_window', {}
|
return 'close_window', {}
|
||||||
|
|
||||||
def on_activated_async(self, view):
|
def on_activated_async(self, view):
|
||||||
@ -72,8 +73,8 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener):
|
|||||||
if (is_markdown_view(view)
|
if (is_markdown_view(view)
|
||||||
and get_settings().get('markdown_live_preview_on_open')
|
and get_settings().get('markdown_live_preview_on_open')
|
||||||
and not vsettings.get(PREVIEW_ENABLED)
|
and not vsettings.get(PREVIEW_ENABLED)
|
||||||
and vsettings.get('syntax') != 'Packages/MarkdownLivePreview/'
|
and vsettings.get('syntax') != 'Packages/MarkdownLivePreview/' + \
|
||||||
'.sublime/MarkdownLivePreviewSyntax'
|
'.sublime/MarkdownLivePreviewSyntax' + \
|
||||||
'.hidden-tmLanguage'):
|
'.hidden-tmLanguage'):
|
||||||
sublime.run_command('new_markdown_live_preview')
|
sublime.run_command('new_markdown_live_preview')
|
||||||
|
|
||||||
@ -105,7 +106,6 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener):
|
|||||||
if show_menus is not None:
|
if show_menus is not None:
|
||||||
window.set_menu_visible(show_menus)
|
window.set_menu_visible(show_menus)
|
||||||
|
|
||||||
|
|
||||||
class MarkdownLivePreviewClearCacheCommand(sublime_plugin.ApplicationCommand):
|
class MarkdownLivePreviewClearCacheCommand(sublime_plugin.ApplicationCommand):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
Fast:
|
Fast:
|
||||||
☐ sync scroll @needsUpdate(because of images)
|
|
||||||
☐ cache image in object when used, so that it's faster @needsTest
|
☐ cache image in object when used, so that it's faster @needsTest
|
||||||
|
|
||||||
Medium:
|
Medium:
|
||||||
@ -7,14 +6,16 @@ Medium:
|
|||||||
☐ use alt attribute for 404 error
|
☐ use alt attribute for 404 error
|
||||||
|
|
||||||
Long:
|
Long:
|
||||||
☐ support hanchor (TOC) @big
|
☐ support anchor (TOC) @big
|
||||||
|
|
||||||
Unknown:
|
Unknown:
|
||||||
☐ check how many times is the show_html function called
|
|
||||||
|
|
||||||
|
|
||||||
___________________
|
___________________
|
||||||
Archive:
|
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)
|
✔ 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)
|
✔ 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)
|
✔ add clear cache command @done Mon 09 Jan 2017 at 18:41 @project(Fast)
|
||||||
|
|||||||
12
default.css
12
default.css
@ -1,6 +1,8 @@
|
|||||||
html {
|
html {
|
||||||
--light-bg: color(var(--background) blend(#999 85%));
|
--light-bg: color(var(--background) blend(#999 85%));
|
||||||
|
--very-light-bg: color(var(--background) blend(#999 92%));
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
padding:10px;
|
padding:10px;
|
||||||
padding-top: 0px;
|
padding-top: 0px;
|
||||||
@ -37,3 +39,13 @@ pre {
|
|||||||
pre code {
|
pre code {
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre code .space {
|
||||||
|
color: var(--light-bg)
|
||||||
|
}
|
||||||
|
|
||||||
|
kbd {
|
||||||
|
padding: 0 5px;
|
||||||
|
background-color: var(--very-light-bg);
|
||||||
|
font-family: "Roboto Mono","Courier New",Courier,monospace;
|
||||||
|
}
|
||||||
|
|||||||
@ -7,13 +7,13 @@ import os.path
|
|||||||
class MLPDevListener(sublime_plugin.EventListener):
|
class MLPDevListener(sublime_plugin.EventListener):
|
||||||
|
|
||||||
def on_post_save(self, view):
|
def on_post_save(self, view):
|
||||||
return
|
# return
|
||||||
if not (os.path.dirname(__file__) in view.file_name() and
|
if not (os.path.dirname(__file__) in view.file_name() and
|
||||||
view.file_name().endswith('.py')):
|
view.file_name().endswith('.py')):
|
||||||
return
|
return
|
||||||
sublime.run_command('reload_plugin', {
|
sublime.run_command('reload_plugin', {
|
||||||
'main': os.path.join(sublime.packages_path(),
|
'main': os.path.join(sublime.packages_path(), 'MarkdownLivePreview',
|
||||||
'MarkdownLivePreview', 'md_in_popup.py'),
|
'MarkdownLivePreview.py'),
|
||||||
'scripts': ['image_manager', 'functions', 'MLPApi',
|
'scripts': ['image_manager', 'functions', 'MLPApi',
|
||||||
'setting_names'],
|
'setting_names'],
|
||||||
'quiet': True
|
'quiet': True
|
||||||
|
|||||||
92
docs/imgs/MarkdownLivePreview-opposite.svg
Normal file
92
docs/imgs/MarkdownLivePreview-opposite.svg
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="100"
|
||||||
|
height="100"
|
||||||
|
viewBox="0 0 99.999996 100"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
sodipodi:docname="MarkdownLivePreview.svg">
|
||||||
|
<defs
|
||||||
|
id="defs4" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#2196f3"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="2.8"
|
||||||
|
inkscape:cx="36.574985"
|
||||||
|
inkscape:cy="6.9424003"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
showborder="true"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1018"
|
||||||
|
inkscape:window-x="-8"
|
||||||
|
inkscape:window-y="-8"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="0"
|
||||||
|
inkscape:showpageshadow="false"
|
||||||
|
units="px"
|
||||||
|
showguides="true"
|
||||||
|
inkscape:guide-bbox="true"
|
||||||
|
inkscape:snap-global="false" />
|
||||||
|
<metadata
|
||||||
|
id="metadata7">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-349.87364,-434.14672)">
|
||||||
|
<g
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:59.90521622px;font-family:Candal;-inkscape-font-specification:Candal;text-align:start;text-anchor:start;opacity:1;fill:#e1ecff;fill-opacity:1;stroke:#ef524f;stroke-width:3.75156426;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
id="text7027"
|
||||||
|
transform="translate(-0.13506381,-12.064395)">
|
||||||
|
<path
|
||||||
|
d="m 352.04084,461.61747 12.16825,0 10.2962,16.08783 10.29621,-16.08783 12.46076,0 0,41.36034 -13.39678,0 0,-22.46445 -9.65269,16.35108 -2.83731,0 -9.97445,-16.35108 0,22.46445 -9.36019,0 0,-41.36034 z"
|
||||||
|
style="fill:#e1ecff;fill-opacity:1;stroke:none"
|
||||||
|
id="path7039"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="matrix(-1,0,0,1,-0.13506381,-12.064395)"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:59.90521622px;font-family:Candal;-inkscape-font-specification:Candal;text-align:start;text-anchor:start;opacity:1;fill:#b9d5ff;fill-opacity:1;stroke:#ef524f;stroke-width:3.75156426;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
id="text7031">
|
||||||
|
<path
|
||||||
|
d="m -447.97656,461.61747 12.16825,0 10.29621,16.08783 10.29621,-16.08783 12.46075,0 0,41.36034 -13.39677,0 0,-22.46445 -9.6527,16.35108 -2.8373,0 -9.97446,-16.35108 0,22.46445 -9.36019,0 0,-41.36034 z"
|
||||||
|
style="fill:#b9d5ff;fill-opacity:1;stroke:none"
|
||||||
|
id="path7036"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
<path
|
||||||
|
style="opacity:0.75;fill:#cde0ff;fill-opacity:1;stroke:none;stroke-width:1.00199997;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 375.63144,496.36803 24.28571,14.02137 24.28572,-14.02137 14.46428,0 -38.75,22.37233 -38.75,-22.37233 z"
|
||||||
|
id="path7081"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 3.8 KiB |
92
docs/imgs/MarkdownLivePreview.svg
Normal file
92
docs/imgs/MarkdownLivePreview.svg
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="100"
|
||||||
|
height="100"
|
||||||
|
viewBox="0 0 99.999996 100"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
sodipodi:docname="MarkdownLivePreview.svg">
|
||||||
|
<defs
|
||||||
|
id="defs4" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="2.8"
|
||||||
|
inkscape:cx="36.574985"
|
||||||
|
inkscape:cy="6.9424003"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
showborder="true"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1018"
|
||||||
|
inkscape:window-x="-8"
|
||||||
|
inkscape:window-y="-8"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="0"
|
||||||
|
inkscape:showpageshadow="false"
|
||||||
|
units="px"
|
||||||
|
showguides="true"
|
||||||
|
inkscape:guide-bbox="true"
|
||||||
|
inkscape:snap-global="false" />
|
||||||
|
<metadata
|
||||||
|
id="metadata7">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-349.87364,-434.14672)">
|
||||||
|
<g
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:59.90521622px;font-family:Candal;-inkscape-font-specification:Candal;text-align:start;text-anchor:start;opacity:1;fill:#5599ff;fill-opacity:1;stroke:#ef524f;stroke-width:3.75156426;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
id="text7027"
|
||||||
|
transform="translate(-0.13506381,-12.064395)">
|
||||||
|
<path
|
||||||
|
d="m 352.04084,461.61747 12.16825,0 10.2962,16.08783 10.29621,-16.08783 12.46076,0 0,41.36034 -13.39678,0 0,-22.46445 -9.65269,16.35108 -2.83731,0 -9.97445,-16.35108 0,22.46445 -9.36019,0 0,-41.36034 z"
|
||||||
|
style="fill:#5599ff;fill-opacity:1;stroke:none"
|
||||||
|
id="path7039"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="matrix(-1,0,0,1,-0.13506381,-12.064395)"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:59.90521622px;font-family:Candal;-inkscape-font-specification:Candal;text-align:start;text-anchor:start;opacity:0.75;fill:#5599ff;fill-opacity:1;stroke:#ef524f;stroke-width:3.75156426;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
id="text7031">
|
||||||
|
<path
|
||||||
|
d="m -447.97656,461.61747 12.16825,0 10.29621,16.08783 10.29621,-16.08783 12.46075,0 0,41.36034 -13.39677,0 0,-22.46445 -9.6527,16.35108 -2.8373,0 -9.97446,-16.35108 0,22.46445 -9.36019,0 0,-41.36034 z"
|
||||||
|
style="fill:#5599ff;fill-opacity:1;stroke:none"
|
||||||
|
id="path7036"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
<path
|
||||||
|
style="opacity:0.75;fill:#aaccff;fill-opacity:1;stroke:none;stroke-width:1.00199997;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 375.63144,496.36803 24.28571,14.02137 24.28572,-14.02137 14.46428,0 -38.75,22.37233 -38.75,-22.37233 z"
|
||||||
|
id="path7081"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 3.9 KiB |
152
docs/index.md
Normal file
152
docs/index.md
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
# Welcome to MarkdownLivePreview's documentation!
|
||||||
|
|
||||||
|
<img src="imgs/MarkdownLivePreview.svg" alt="MarkdownLivePreview's logo"
|
||||||
|
style="width: 400px; margin: auto; display: block;">
|
||||||
|
|
||||||
|
MarkdownLivePreview is a [Sublime Text 3][st] plugin to preview your markdown as you type,
|
||||||
|
*right in Sublime Text itself*, without *any* dependency!
|
||||||
|
|
||||||
|
It's very easy to use, but there's a few things that you might want to be aware of... So, let's
|
||||||
|
get started
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Using Package Control
|
||||||
|
|
||||||
|
You can really easily install MarkdownLivePreview by using [Package Control][pck-con].
|
||||||
|
|
||||||
|
If it's not already, you need to [install it][install-pck-con] first.
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
If you're using the latest build of Sublime Text 3, you can just do
|
||||||
|
*Tools → Install Package Control…*
|
||||||
|
|
||||||
|
- Open up the command palette (<kbd>ctrl+shift+p</kbd>)
|
||||||
|
- Search up `Package Control: Install Package` (might take a few seconds)
|
||||||
|
- In the panel that just showed up, search for `MarkdownLivePreview`
|
||||||
|
|
||||||
|
Done! You have now access to every single features of MarkdownLivePreview! :wink:
|
||||||
|
|
||||||
|
### Using `git`
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ cd "%APPDATA%\Sublime Text 3\Packages" # on Windows
|
||||||
|
$ cd ~/Library/Application\ Support/Sublime\ Text\ 3 # on Mac
|
||||||
|
$ cd ~/.config/sublime-text-3 # on Linux
|
||||||
|
|
||||||
|
$ git clone "https://github.com/math2001/MarkdownLivePreview"
|
||||||
|
```
|
||||||
|
|
||||||
|
> So, which one do I pick?!
|
||||||
|
|
||||||
|
I depends of what you want to do. If you want to just use MarkdownLivePreview, pick the first
|
||||||
|
solution, you'll get every update automatically. But if you want to contribute, then choose the
|
||||||
|
second solution.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Previewing
|
||||||
|
|
||||||
|
As told in the introduction, MarkdownLivePreview is very easy to use:
|
||||||
|
|
||||||
|
- open a markdown file
|
||||||
|
- press <kbd>alt+m</kbd>
|
||||||
|
- or select in the command palette `MarkdownLivePreview: Edit Current File`
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
The preview of unsaved markdown files is currently not supported. It should be fixed soon.
|
||||||
|
|
||||||
|
!!! tip
|
||||||
|
[Markdown Extended][] is supported too!
|
||||||
|
|
||||||
|
That's it. That's all you need to do to preview your markdown!
|
||||||
|
|
||||||
|
### Custom CSS
|
||||||
|
|
||||||
|
If you want to, you can add custom `CSS` to the MarkdownLivePreview's default stylesheet.
|
||||||
|
|
||||||
|
Just search for `MarkdownLivePreview: Edit Custom CSS File` in the command palette
|
||||||
|
(<kbd>ctrl+shift+p</kbd>). It will open a file in which you can add some CSS that will be *added* to
|
||||||
|
the normal CSS.
|
||||||
|
|
||||||
|
!!! bug
|
||||||
|
Comments in the CSS is interpreted weirdly by Sublime Text's phantoms. After a few tests, I
|
||||||
|
think that everything that is bellow a comment is ignored.
|
||||||
|
|
||||||
|
If you want to be sure that your CSS works, don't put any comments in it
|
||||||
|
|
||||||
|
#### Share your tweaks!
|
||||||
|
|
||||||
|
If you think that other users would enjoy your added CSS, then raise an issue, or PR the
|
||||||
|
[GitHub repo][] to share your tweaks!
|
||||||
|
|
||||||
|
### Clearing the cache
|
||||||
|
|
||||||
|
MarkdownLivePreview has a cache system to store images you load from internet. You can clear this
|
||||||
|
cache by searching up in the command palette `MarkdownLivePreview: Clear the cache`.
|
||||||
|
|
||||||
|
!!! tip
|
||||||
|
The cache is one simple file called `MarkdownLivePreviewCache`, which is located in your temp
|
||||||
|
folder. To know where it is, you can open the Sublime Text console (<kbd>ctrl+`</kbd> or
|
||||||
|
*View → Show Console*), and paste this in:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import tempfile; print(tempfile.gettempdir())
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom settings for the preview
|
||||||
|
|
||||||
|
Sublime Text makes it easy to set custom settings for a specific *type* of view. For example,
|
||||||
|
`markdown`, `python`, etc. MarkdownLivePreview takes advantage of that: the preview view (the view
|
||||||
|
on the right) is a specific syntax (called — sorry for the originality —
|
||||||
|
`MarkdownLivePreviewSyntax`). So, to change this, you can focus the right view, open up the command
|
||||||
|
palette (<kbd>ctrl+shift+p</kbd>), and search up `Preferences: Settings — Syntax Specific`. In here,
|
||||||
|
you can specify any settings that is going to be applied only to this view.
|
||||||
|
|
||||||
|
### The hacky part
|
||||||
|
|
||||||
|
In fact, MarkdownLivePreview parses those settings, and looks for specific ones:
|
||||||
|
|
||||||
|
- `show_tabs`
|
||||||
|
- `show_minimap`
|
||||||
|
- `show_status_bar`
|
||||||
|
- `show_sidebar`
|
||||||
|
- `show_menus`
|
||||||
|
|
||||||
|
Those settings aren't supported by default because they affect the entire *window* instead of just
|
||||||
|
the view. But MarkdownLivePreview will look for them in your *preview*'s settings, and hide/show the
|
||||||
|
tabs, the minimap, etc...
|
||||||
|
|
||||||
|
As you probably guessed those settings takes a bool for value (`true` or `false`).
|
||||||
|
|
||||||
|
### Recommendation
|
||||||
|
|
||||||
|
Here's what I'd recommend (and use):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"show_menus": false,
|
||||||
|
"show_tabs": false,
|
||||||
|
"show_minimap": false,
|
||||||
|
"gutter": false,
|
||||||
|
"rulers": [],
|
||||||
|
"word_wrap": true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! tip
|
||||||
|
On Windows at least, you can press <kbd>alt</kbd> to focus (so show) the menu, even if they're
|
||||||
|
originally hidden
|
||||||
|
|
||||||
|
That's it! I hope you'll enjoy using this package! If it's the case, please let your friends know
|
||||||
|
about it, and even myself by sending me a [tweet][] or staring the repo
|
||||||
|
<iframe
|
||||||
|
src="https://ghbtns.com/github-btn.html?user=math2001&repo=MarkdownLivePreview&type=star&count=true&size=large"
|
||||||
|
frameborder="0" scrolling="0" width="160px" height="30px"></iframe>!
|
||||||
|
|
||||||
|
[st]: https://sublimetext.com
|
||||||
|
[Markdown Extended]: https://packagecontrol.io/packages/Markdown%20Extended
|
||||||
|
[pck-con]: https://packagecontrol.io
|
||||||
|
[install-pck-con]: https://packagecontrol.io/installation
|
||||||
|
[tweet]: https://twitter.com/_math2001
|
||||||
|
[GitHub repo]: https://github.com/math2001/MarkdownLivePreview/issues
|
||||||
@ -23,8 +23,8 @@ def replace_img_src_base64(html, basepath):
|
|||||||
path, end = get_content_till(html, '"', start=index + len(tag_start))
|
path, end = get_content_till(html, '"', start=index + len(tag_start))
|
||||||
if ''.join(path).startswith('data:image/'):
|
if ''.join(path).startswith('data:image/'):
|
||||||
continue
|
continue
|
||||||
if ''.join(path).startswith(tuple(get_settings().get('load_from_internet'
|
if ''.join(path).startswith(tuple(get_settings().get('load_from_internet' + \
|
||||||
'_when_starts'))):
|
'_when_starts', []))):
|
||||||
image = ImageManager.get(''.join(path))
|
image = ImageManager.get(''.join(path))
|
||||||
image = image or loading
|
image = image or loading
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ def replace_img_src_base64(html, basepath):
|
|||||||
return ''.join(html)
|
return ''.join(html)
|
||||||
|
|
||||||
def is_markdown_view(view):
|
def is_markdown_view(view):
|
||||||
return 'markdown' in view.scope_name(0)
|
return 'markdown' in view.scope_name(0)
|
||||||
|
|
||||||
def to_base64(path=None, content=None):
|
def to_base64(path=None, content=None):
|
||||||
if path is None and content is None:
|
if path is None and content is None:
|
||||||
|
|||||||
@ -10,10 +10,10 @@ Thanks for installing MarkdownLivePreview! I hope you'll enjoy using it!
|
|||||||
Quick Start:
|
Quick Start:
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
To enable MarkdownLivePreview, you need to me on a markdown view (works with
|
To enable MarkdownLivePreview, you need to be on a markdown view (works with
|
||||||
Markdown Extended). Then just press `alt+m`, or search up in the command
|
Markdown Extended). Then just press `alt+m`, or search up in the command
|
||||||
palette: 'MarkdownLivePreview: Toggle'. Hit enter and you're done. As soon as
|
palette: 'MarkdownLivePreview: Toggle'. Hit enter and you're done. As soon as
|
||||||
you'll type anything in, it'll show up the preview in a new group.
|
you type anything in, it'll show up with the preview in a new group.
|
||||||
|
|
||||||
Say thanks:
|
Say thanks:
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|||||||
35
mkdocs.yml
Normal file
35
mkdocs.yml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
site_name: MarkdownLivePreview
|
||||||
|
theme: material
|
||||||
|
repo_name: math2001/MarkdownLivePreview
|
||||||
|
repo_url: https://github.com/math2001/MarkdownLivePreview
|
||||||
|
site_description: Sublime Text 3 Plugin MarkdownLivePreview's documentation
|
||||||
|
site_author: math2001
|
||||||
|
|
||||||
|
markdown_extensions:
|
||||||
|
- toc(permalink=true)
|
||||||
|
- pymdownx.arithmatex
|
||||||
|
- pymdownx.betterem(smart_enable=all)
|
||||||
|
- pymdownx.caret
|
||||||
|
- pymdownx.critic
|
||||||
|
- pymdownx.emoji:
|
||||||
|
emoji_generator: !!python/name:pymdownx.emoji.to_svg
|
||||||
|
- pymdownx.inlinehilite
|
||||||
|
- pymdownx.magiclink
|
||||||
|
- pymdownx.mark
|
||||||
|
- pymdownx.smartsymbols
|
||||||
|
- pymdownx.superfences
|
||||||
|
- pymdownx.tasklist(custom_checkbox=true)
|
||||||
|
- pymdownx.tilde
|
||||||
|
- admonition
|
||||||
|
- codehilite
|
||||||
|
|
||||||
|
extra:
|
||||||
|
logo: imgs/MarkdownLivePreview-opposite.svg
|
||||||
|
palette:
|
||||||
|
primary: Blue
|
||||||
|
accent: Indigo
|
||||||
|
social:
|
||||||
|
- type: github
|
||||||
|
link: https://github.com/math2001
|
||||||
|
- type: twitter
|
||||||
|
link: https://twitter.com/_math2001
|
||||||
60
sample.md
60
sample.md
@ -1,52 +1,28 @@
|
|||||||
# DuckDuckGo - The Search engine you'll fall in love
|
# Hello world
|
||||||
|
|
||||||
Hope you'll enjoy using MarkdownLivePreview!
|
|
||||||
|
|
||||||
|
Some `inline code` with *italic* and **bold** text.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
print('Hello world')
|
import this
|
||||||
if DEBUG:
|
if you is moods.curious:
|
||||||
print('DEBUG_MODE on')
|
print('then do it!')
|
||||||
```
|
```
|
||||||
|
|
||||||
> Only a fool knows everything. A wise man knows how little he knows
|
<kbd>ctrl+\`</kbd> or *View → Show Console* and paste `import this`!
|
||||||
|
|
||||||
The only think I know right now is that Boxy Theme's just awesome.
|
> Perfect programmers do NOT need comments.
|
||||||
|
|
||||||
t
|
- to be efficient
|
||||||
|
- you need
|
||||||
|
- todos
|
||||||
|
|
||||||
h
|

|
||||||
|
|
||||||
i
|
Some plugin I just *need*:
|
||||||
|
|
||||||
s
|
- [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)
|
||||||
i
|
- [PlainTasks](https://packagecontrol.io/packages/PlainTasks)
|
||||||
|
- [JSONComma](https://packagecontrol.io/packages/JSONComma)
|
||||||
s
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
-
|
|
||||||
|
|
||||||
a
|
|
||||||
|
|
||||||
-
|
|
||||||

|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
t
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
e
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
s
|
|
||||||
|
|
||||||
t
|
|
||||||
|
|||||||
Reference in New Issue
Block a user