diff --git a/MLPApi.py b/MLPApi.py index 36dca8a..4d75115 100644 --- a/MLPApi.py +++ b/MLPApi.py @@ -24,7 +24,11 @@ windows_phantom_set = {} def plugin_loaded(): global DEFAULT_STYLE_FILE - DEFAULT_STYLE_FILE = sublime.load_resource('Packages/MarkdownLivePreview/default.css') + if os.path.exists(os.path.join(__folder__, 'default.css')): + with open(os.path.join(__folder__, 'default.css')) as fp: + DEFAULT_STYLE_FILE = fp.read() + else: + DEFAULT_STYLE_FILE = sublime.load_resource('Packages/MarkdownLivePreview/default.css') def get_preview_name(md_view): file_name = md_view.file_name() @@ -65,7 +69,6 @@ def markdown2html(md, basepath): # exception, again, because
aren't supported by the phantoms
html = html.replace(' espace;', '.')
html = replace_img_src_base64(html, basepath=os.path.dirname(basepath))
- sublime.set_clipboard(html)
return html
def show_html(md_view, preview):
diff --git a/default.css b/default.css
index 888dfcd..2599680 100644
--- a/default.css
+++ b/default.css
@@ -43,6 +43,14 @@ pre code {
pre code .space {
color: var(--light-bg)
}
+pre.table {
+ background-color: var(--backgroud);
+}
+pre.table code {
+ background-color: var(--backgroud);
+ padding: 0;
+ margin: 0;
+}
kbd {
padding: 0 5px;
diff --git a/functions.py b/functions.py
index dda3699..0700d04 100644
--- a/functions.py
+++ b/functions.py
@@ -4,7 +4,7 @@ import os.path
import sublime
import re
from .image_manager import ImageManager
-
+from bs4 import BeautifulSoup
def plugin_loaded():
global error404, loading
@@ -90,9 +90,16 @@ def get_settings():
def pre_with_br(html):
"""Because the phantoms of sublime text does not support blocks
this function replaces every \n with a
in a """
+ # Need to use bs4
+ soup = BeautifulSoup(html)
+ for pre in soup.find_all('pre'):
+ code = pre.find('code')
+ code.replaceWith(BeautifulSoup(''.join(str(node) for node in pre.contents) \
+ .replace('\n', '
').replace(' ', '.'), 'html.parser'))
+ return soup.prettify().replace('
', '
')
while True:
- obj = re.search(r'(.*?)
', html, re.DOTALL)
+ obj = re.search(r'(.*?)
', html, re.DOTALL)
if not obj:
break
html = list(html)
diff --git a/lib/pre_tables.py b/lib/pre_tables.py
index b041831..29cb849 100644
--- a/lib/pre_tables.py
+++ b/lib/pre_tables.py
@@ -53,7 +53,7 @@ def pre_table(s_table):
for i, cell in enumerate(row):
if cols_width[i] < len(cell.text):
cols_width[i] = len(cell.text)
- text = ''
+ text = ''
for i, row in enumerate(rows):
for j, cell in enumerate(row):
text += '| ' + ''.join(str(node) for node in cell.contents) + ' ' * (cols_width[j] - len(cell.text))
diff --git a/sample.md b/sample.md
index 1bddc52..931914d 100644
--- a/sample.md
+++ b/sample.md
@@ -8,6 +8,7 @@ if you is moods.curious:
print('then do it!')
```
+
ctrl+\` or *View → Show Console* and paste `import this`!
> Perfect programmers do NOT need comments.