diff --git a/MLPApi.py b/MLPApi.py
index 4d75115..29e199d 100644
--- a/MLPApi.py
+++ b/MLPApi.py
@@ -55,20 +55,23 @@ def get_style():
return content
def markdown2html(md, basepath):
- html = ''
- html += '\n'.format(get_style())
+ html = '\n'.format(get_style())
# pre_with_br
html += pre_with_br(pre_tables(md2.markdown(md, extras=['fenced-code-blocks',
'no-code-highlighting', 'tables'])))
# 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 = strip_html_comments(html)
+
+ # Beautiful uses the
but the sublime phantoms do not support them...
+ html = html.replace('
', '
')
html = html.replace(' ', ' espace;') # save where are the spaces
-
# 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/functions.py b/functions.py
index b5f28f2..ace0776 100644
--- a/functions.py
+++ b/functions.py
@@ -4,13 +4,18 @@ import os.path
import sublime
import re
from .image_manager import ImageManager
-from bs4 import BeautifulSoup
+from bs4 import BeautifulSoup, Comment as html_comment
def plugin_loaded():
global error404, loading
loading = sublime.load_resource('Packages/MarkdownLivePreview/loading.txt')
error404 = sublime.load_resource('Packages/MarkdownLivePreview/404.txt')
+def strip_html_comments(html):
+ soup = BeautifulSoup(html, 'html.parser')
+ for element in soup.find_all(text=lambda text: isinstance(text, html_comment)):
+ element.extract()
+ return str(soup)
def replace_img_src_base64(html, basepath):
"""Really messy, but it works (should be updated)"""
@@ -95,4 +100,4 @@ def pre_with_br(html):
code = pre.find('code')
code.replaceWith(BeautifulSoup(''.join(str(node) for node in pre.contents) \
.replace('\n', '
').replace(' ', '.'), 'html.parser'))
- return str(soup).replace('
', '
')
+ return str(soup)
diff --git a/sample.md b/sample.md
index f45ac16..b57a290 100644
--- a/sample.md
+++ b/sample.md
@@ -1,5 +1,7 @@
# Hello world
+
+
Some `inline code` with *italic* and **bold** text.
```python