soscripted / sox

Stack Overflow Extras: a userscript for the Stack Exchange websites to add a bunch of optional toggle-able features
http://stackapps.com/q/6091/
MIT License
72 stars 15 forks source link

Convert links to URLs that are images but not in the correct markdown format to the correct format #399

Open SmartManoj opened 5 years ago

SmartManoj commented 5 years ago

Tool in Editing Post for Image Links to this format [![enter image description here][number]][number]

shu8 commented 5 years ago

Thanks for the feature request. Would you mind adding a quick example of what you'd like the feature to do? A before and after markdown sample would be great!

On Mon, 17 Jun 2019, 08:10 SmartManoj, notifications@github.com wrote:

Tool in Editing Post for Image Links to this format [![enter image description here][number]][number]

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/soscripted/sox/issues/399?email_source=notifications&email_token=ACDQ3DWLLZCUZHNKCP7GOCDP242GJA5CNFSM4HYTZBV2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GZZ3V2Q, or mute the thread https://github.com/notifications/unsubscribe-auth/ACDQ3DV7L33H5KWJ6DNLRPDP242GJANCNFSM4HYTZBVQ .

SmartManoj commented 5 years ago

[img](https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png)

To

[![img][n]][n]

[n]:https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png

where n is total no of links +1


[img][x]

To

[![img][x]][x]

shu8 commented 5 years ago

By [img](https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png) do you mean ![img](https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png), or are you looking for the feature to determine which links are images and also prepend the ! before them?

SmartManoj commented 5 years ago

First one ; Second also better by checking for png , jpg

shu8 commented 5 years ago

I'm a bit unsure about this feature and useful it would be. Do you have a particular use case for wanting to convert between the two formats?

SmartManoj commented 5 years ago

It will be useful when editing old post.

SmartManoj commented 5 years ago

By [img](https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png) do you mean ![img](https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png), or are you looking for the feature to determine which links are images and also prepend the ! before them?

Not like this, [img](https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png) to ![[img](https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png)](https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png) What's the recommended syntax for an image with a link?

SmartManoj commented 5 years ago

Or It will be better to zoom out image instead of opening.

shu8 commented 5 years ago

It will be useful when editing old post.

Sorry, I still can't see the use case in editing old posts :/ I am fairly sure both image formats should work on all posts!

Or It will be better to zoom out image instead of opening.

Could you expand on this please? I'm not sure I understand what you mean here!

SmartManoj commented 5 years ago

[img](https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png) to ![[img](https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png)](https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png)

Some people post image as hyperlink

[img](image link)

Recommended way

![[img][1]][1]
[1]:image link

Or It will be better to zoom out image instead of opening.

Like this https://codepen.io/ongtiffany/pen/BoOeQV?editors=0100

shu8 commented 5 years ago

Ah thanks, I think I've understood now. This seems like two feature requests now:

  1. Detect and convert links to URLs that are images but not in the correct markdown format to the correct format
  2. Open links to images as an enlarged modal instead of a new tab

Is this right? if so, please could you make another issue for number 2? :)

SmartManoj commented 5 years ago

S. #404 done

shu8 commented 5 years ago

Thanks. I've marked this as 'contributions welcome', as I don't think I'll have time to get this done anytime soon, and at first glance it doesn't seem to be extremely trivial.