I haven't had a detailed look but yeah, I think most of this could be rolled into a Google App Script and made into an add-on. I actually did something similar years ago but for exporting to html for email, going through a few libraries for html and CSS manipulation and inlining.