31 Commits

Author SHA1 Message Date
7c37a9e413 potential fix for fontscaling 2025-04-24 20:14:10 +02:00
9f243f09c9 fix 2025-04-24 20:11:19 +02:00
731f2def96 loggin 2025-04-24 20:08:56 +02:00
b3ffe8bf55 Update package 2025-04-24 20:05:55 +02:00
837979232e fix because we are using python 3.3 sic 2025-04-24 20:00:38 +02:00
e05516ab22 log font_scale 2025-04-24 19:58:47 +02:00
3dd7b5a18d made bs4 and soupsieve standalone in this project 2025-04-24 19:26:20 +02:00
e0daa147f1 fix import 2025-04-24 17:06:45 +02:00
b29d054de2 new build 2025-04-24 16:49:41 +02:00
6379b673fc fix imports 2025-04-24 16:40:24 +02:00
35c8a954d0 add feature:
setting to increase font scale
2025-04-24 14:18:29 +02:00
cf68b2c202 Set the maxwidth for images (fix #48)
It didn't look pretty when images where larger than the viewport, and it
"broke" word wrap (because it stretched the phantom, and hence lines
wrapped further, see #34)

Sublime Text's minihtml only supports width and height attributes on
img tags, therefore, we have to determine the aspect ratio of the images
ourselves if we want to set a maxsize (so that we can set the height).

We use a hacky function copy pasted from stackoverflow to determine the
size of common format of images using std lib python.
2019-11-16 14:56:03 +11:00
c10bc95e54 remove utils.py file; use a setting file for delay between updates
utils.py contained two functions. One which wasn't used, and another,
get_settings() which I moved to MarkdownLivePreview.py

Add an entry to the command palette to edit the settings
2019-11-16 14:19:46 +11:00
84fb15aec3 update stylesheet to spread pre blocks (fix #56) 2019-11-16 11:16:58 +11:00
192f61bf0c improve caching of images
First, we used two caches. Turns out that lru_cache wasn't needed, the
dict works perfectly fine on it's own.

Second, we now also cache local images, so that we don't have to read
them off the filesystem and convert them to base64 on every keystroke

Maybe there should be a maximum size on that cache dict, but I doubt
anyone would actually run into any trouble this cache taking too much
ram.
2019-11-16 10:16:12 +11:00
2785df74ce Format everything with black
Follow the readme's instruction haha
2019-11-16 09:57:45 +11:00
0f5630c3dc Set the preview's name (in the tab)
just a one liner
2019-11-16 08:28:04 +11:00
c14c28b56b fix the flickering by delaying and throwing
Explanation coming on my blog, math2001.github.io, something like
"lessons learned from re writing MarkdownLivePreview"
2019-11-16 07:50:55 +11:00
0dea8afba4 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 />
2019-11-15 15:19:15 +11:00
e3896a6b3d 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
2019-11-15 15:02:31 +11:00
6016f07cd1 add line breaks for pre 2019-11-15 14:52:20 +11:00
c0c9867cc8 move resources.py to MarkdownLivePreview.py
Having an extra file is just a pain because you have to save it manually
for ST to reload, and it was small and created way more trouble than it
needed to... It fits really nicely in there anyway

And add some nice CSS
2019-11-15 13:33:58 +11:00
5f2cac54e8 use a resource system to load images and stylesheet 2019-11-15 07:21:41 +11:00
8c1012eb8c Remove entry in phantom_sets when markdown_view is closed
Otherwise the object would keep on growing forever. It probably would
never ever be a problem for anyone, but it just makes me feel better
2019-11-14 21:33:37 +11:00
ef9b2daf6d Load images from the internet using an in memory cache
As soon as the plugin is reloaded, or the editor restarted, the images
must be reloaded. Maybe we could use a file cache...
2019-11-14 19:30:26 +11:00
bae26fc452 Viewing images works for local files
We have to make sure that everything is converted to base64 (and
replaced in the src attribute) because otherwise ST3 messes up the
height of the images
2019-11-14 17:28:47 +11:00
5738f6b5ff render the preview as soon as the markdown file loads 2019-11-14 15:56:55 +11:00
6bb8e6ebaa update preview when the user types
We don't have any delay in between updates (because i'm scared of
threading), which has a few problem:

1. probably really sluggish on slow systems
2. probably slow for readmes with images (need to test)
3. flickers (the phantoms are updated too quickly, so sometimes it
doesn't replace the old one smoothly)

BUG: the preview doesn't load when we preview the markdown file
2019-11-14 15:56:22 +11:00
61cf2984eb Fix restoration of markdown_view as an original_view for unsaved files
It use to ask for confirmation (to save) because on_pre_close is run
after this dialog. Hence, we set the markdown_view as scratch for
unsaved files. :^)
2019-11-14 11:24:31 +11:00
7f7dcd6ba8 Restore the markdown_view as an original_view
See the top of MarkdownLivePreview.py for terminology

Doesn't work well for unsaved files, as pre_close is triggered after the
confirmation dialog
2019-11-14 11:20:20 +11:00
9a8ac3886e Open current markdown file in a new window
It works for saved and unsaved files. Maybe unsaved file's content
should be written to a temporary file in case we crash, so that the user
doesn't lose all it's content.
2019-11-13 13:57:24 +11:00