aprzn123 / TheThirdCan

A browser extension designed to improve https://twocansandstring.com
MIT License
7 stars 4 forks source link

Suggestion: SVG support #7

Open roxwize opened 1 year ago

roxwize commented 1 year ago

This could be infeasible. I have no idea. With enough tenacity and node.js packages it could work. I intend to do it the way Wikipedia does (use a renderer to convert it to PNG, then embed the PNG in place of the SVG), but anything else could do (such as rendering it to a canvas element instead).

aprzn123 commented 1 year ago

Doesn't HTML have native SVG rendering?

roxwize commented 1 year ago

I was unaware of that. If that's the case this should be easy, but I think using rendering as PNG would be easier. If SVG can't be rendered by the browser either for compatibility reasons or if it just doesn't work just using a rendered PNG in an img element should universally work regardless, and be much easier and more reliable to modify if necessary. But I don't know anything, so if that seems like the easiest option it might be a good idea to go for it.

aprzn123 commented 1 year ago

I'm just not sure how we'd render SVG to PNG client side. Also, preferably we should avoid incorporating node packages as much as possible (at least, I want to avoid having a build step--that's why we're not using typescript lol). Is there a particular package that you're looking at for rendering SVGs to images? Also, how do you propose users send the SVGs?

roxwize commented 1 year ago

It could either be wrapped in the pre-existing image tag or a special svg tag. Also Pablo might work as a module that hopefully won't require Node to use; we should just be able to import it directly and use that to convert any SVGs to an image somehow. It won't work on mobile browsers or IE8 and below, but meh. Native SVG rendering isn't supported on mobile browsers either, as far as I can tell.

aprzn123 commented 1 year ago

We're not supporting mobile or IE anyway, so that should be fine

roxwize commented 1 year ago

Alright. I'll see if I can get something working then; just as a rough prototype.