sotte / presenting.vim

A simple tool for presenting slides in vim based on text files.
MIT License
300 stars 50 forks source link

image2ascii for markdown images #43

Open Maddin-619 opened 2 years ago

Maddin-619 commented 2 years ago

I recently used this plugin for a presentation in my company and it was so cool. I thought it was nice using some images too, so I made a little patch: If the markdown file includes an image link, the image gets converted with the command line tool image2ascii and centered in the presentation buffer. If the url dosn't exist the alt text gets printed.

In the terminal image2ascii can get the image width and height, but from vim script that didn't worked. So it is necessary to pass the width and height manually. I found a markdown extension where the image size could be passed after the url with an = sign prefix, so I used these format:

![alt text](./images/1200px-Vimlogo.svg.png =55x35)

Here is an example. The cover page of my presentation :) image

P.S. Since it is October can u please lable this PR that it gets accepted: https://hacktoberfest.digitalocean.com/resources/participation Thank you!

sotte commented 2 years ago

Hey @Maddin-619, thanks for the PR! This looks like a nice feature and I'm happy to merge it.

Please add documentation for this feature in the README, the vim docs, and also add a md example.

normen commented 2 years ago

After finding the right image2ascii (theres also a python command with the same name but different parameters) I found that the width/height issue can also be solved by using the -r parameter - seems easier as it keeps the aspect ratio?

Maddin-619 commented 2 years ago

You are right. This is much more comfortable. Should we drop the with and height in favor of the ratio or should we accept both?

normen commented 2 years ago

I guess having both would be nice but it would also mean more parsing - no idea whats the best way here, maybe in the form of actual URL GET parameters? Like folder/myimage.jpg?r=9&w=10&h=10? (ofc all together don't make sense)

sotte commented 2 years ago

I actually had the same issue when I was testing the MR, but I forgot to post it here.

We should also mention what the "right image2ascii version" is and how to install it.

normen commented 2 years ago

We should also mention what the "right image2ascii version" is and how to install it.

Its actually in the PR notes and the vim manual of this PR, I just didn't rtfm 😅 I knew of "the other" image2ascii and so just assumed thats the one.. Maybe in a second step the command and parameters could even be made variables so one can use the ascii-fier of choice.

sotte commented 2 years ago

@Maddin-619 thanks for the additions. Do you think this is ready to be merged?

Maddin-619 commented 2 years ago

I did not implement an exchangable image2ascii program as suggested. Stick with the golang tool for now and this works just fine with optional ratio or with and height params in http query style. So in my opinion this could be merged now, doing the exchangable thing maybe in abother PR.