fix indentation in pre in preview

Again, this is a dodgy hack: replace spaces with dot with the color
exactly like the background, because otherwise ST ignores it, even in
pre
This commit is contained in:
Mathieu PATUREL
2019-11-15 15:02:31 +11:00
parent 6016f07cd1
commit e3896a6b3d
4 changed files with 15 additions and 8 deletions

View File

@ -207,7 +207,7 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener):
resources
)
# print(html)
print(repr(html))
self.phantom_sets[markdown_view.id()].update([
sublime.Phantom(sublime.Region(0), html, sublime.LAYOUT_BLOCK,

View File

@ -6,7 +6,9 @@ what the hell...
```python
import this
# you should try this
if input("answer yes") != 'yes':
print("Really?")
```
this flickering is really annoying...

View File

@ -64,15 +64,17 @@ def markdown2html(markdown, basepath, re_render, resources):
# FIXME: how do tables look? should we use ascii tables?
# FIXME: pre aren't handled by ST3. The require manual adjustment
br = soup.new_tag('br')
# pre aren't handled by ST3. The require manual adjustment
for pre_element in soup.find_all('pre'):
# select the first child, <code>
code_element = next(pre_element.children)
# FIXME: this line sucks, but can we do better?
code_element.replace_with(
bs4.BeautifulSoup(str(code_element).replace('\n', '<br>'), "html.parser"))
# FIXME: this method sucks, but can we do better?
fixed_pre = str(code_element) \
.replace('\n', '<br>')\
.replace(' ', '<i class="space">.</i>')
code_element.replace_with(bs4.BeautifulSoup(fixed_pre, "html.parser"))
# FIXME: highlight the code using Sublime's syntax

View File

@ -38,3 +38,6 @@ pre code {
padding: 0;
}
i.space {
color: var(--very-light-bg);
}