fix clipping of files after pre
The aim is to replace every \n in a <pre> with a <br /> because st doesn't support pre. However, ST doesn't support <br/> for some reason, only <br> or <br />. We use to add some <br>s, but BeautifulSoup automatically adds a <br/> when it sees a <br> (close the tag), which causes the clipping of the rest of the file by ST. But if we replace every \n with a <br />, BeautifulSoup automatically replaces it with <br/> (= ST bug) So, we do exactly that, except that at the very end, when markdown2html returns, we replace every <br/> with a <br />
This commit is contained in:
@ -71,14 +71,15 @@ def markdown2html(markdown, basepath, re_render, resources):
|
||||
|
||||
# FIXME: this method sucks, but can we do better?
|
||||
fixed_pre = str(code_element) \
|
||||
.replace('\n', '<br>')\
|
||||
.replace(' ', '<i class="space">.</i>')
|
||||
.replace(' ', '<i class="space">.</i>') \
|
||||
.replace('\n', '<br />')
|
||||
|
||||
code_element.replace_with(bs4.BeautifulSoup(fixed_pre, "html.parser"))
|
||||
|
||||
# FIXME: highlight the code using Sublime's syntax
|
||||
|
||||
return "<style>\n{}\n</style>\n\n{}".format(resources['stylesheet'], soup)
|
||||
# FIXME: report that ST doesn't support <br/> but does work with <br />... WTF?
|
||||
return "<style>\n{}\n</style>\n\n{}".format(resources['stylesheet'], soup).replace('<br/>', '<br />')
|
||||
|
||||
def get_base64_image(path, re_render):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user