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.
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.
This is a weird merge. I had re-written everything in a separate
repository, and basically wanted that new repo (update) to be the new
master of this repository, whilst preserving the history of the update
repo.
Here's what I did:
$ git remote add update <path to update>
$ git fetch update
$ git merge -X theirs --allow-unrelated-histories update/master
$ # remove extra files
$ git commit --amend
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 />
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