remove .prettify() @ pre_with_pr (bs4);
fix spaces in tables too
This commit is contained in:
@ -69,6 +69,7 @@ def markdown2html(md, basepath):
|
|||||||
# 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, basepath=os.path.dirname(basepath))
|
html = replace_img_src_base64(html, basepath=os.path.dirname(basepath))
|
||||||
|
sublime.set_clipboard(html)
|
||||||
return html
|
return html
|
||||||
|
|
||||||
def show_html(md_view, preview):
|
def show_html(md_view, preview):
|
||||||
|
|||||||
@ -37,7 +37,7 @@ pre {
|
|||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
pre code {
|
pre code {
|
||||||
padding-left: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre code .space {
|
pre code .space {
|
||||||
|
|||||||
13
functions.py
13
functions.py
@ -96,15 +96,4 @@ def pre_with_br(html):
|
|||||||
code = pre.find('code')
|
code = pre.find('code')
|
||||||
code.replaceWith(BeautifulSoup(''.join(str(node) for node in pre.contents) \
|
code.replaceWith(BeautifulSoup(''.join(str(node) for node in pre.contents) \
|
||||||
.replace('\n', '<br/>').replace(' ', '<i class="space">.</i>'), 'html.parser'))
|
.replace('\n', '<br/>').replace(' ', '<i class="space">.</i>'), 'html.parser'))
|
||||||
return soup.prettify().replace('<br/>', '<br />')
|
return str(soup).replace('<br/>', '<br />')
|
||||||
|
|
||||||
while True:
|
|
||||||
obj = re.search(r'<pre (?:class="table")?>(.*?)</pre>', html, re.DOTALL)
|
|
||||||
if not obj:
|
|
||||||
break
|
|
||||||
html = list(html)
|
|
||||||
html[obj.start(0):obj.end(0)] = '<pre >' + ''.join(html[obj.start(1):obj.end(1)]) \
|
|
||||||
.replace('\n', '<br>') \
|
|
||||||
.replace(' ', ' ') + '</pre>'
|
|
||||||
html = ''.join(html)
|
|
||||||
return html
|
|
||||||
|
|||||||
@ -56,7 +56,8 @@ def pre_table(s_table):
|
|||||||
text = '<pre class="table"><code>'
|
text = '<pre class="table"><code>'
|
||||||
for i, row in enumerate(rows):
|
for i, row in enumerate(rows):
|
||||||
for j, cell in enumerate(row):
|
for j, cell in enumerate(row):
|
||||||
text += '| ' + ''.join(str(node) for node in cell.contents) + ' ' * (cols_width[j] - len(cell.text))
|
text += '| ' + ''.join(str(node) for node in cell.contents) \
|
||||||
|
+ ' ' * (cols_width[j] - len(cell.text) + 1)
|
||||||
text += '|\n'
|
text += '|\n'
|
||||||
text += '</pre></code>'
|
text += '</pre></code>'
|
||||||
return text
|
return text
|
||||||
|
|||||||
Reference in New Issue
Block a user