Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Are there any tools that transform HTML and other files? For example, lets say I have an <img> tag with a src attribute that points to a local image. Can I automatically replace that with a <picture> tag with various formats (jpg, webp, avif) and sizes?


I think Parcel[0] is what you want for that use-case.[1]

[0] https://parceljs.org/

[1] https://parceljs.org/recipes/image/


Rehype is an HTML processor with an ecosystem of plugins: https://github.com/rehypejs/rehype/


In ESBuild you’ll need a plugin for this. The plugin API is really simple but you’ll likely be gluing other tools together to achieve it.


SGML can transform HTML and all other forms of markup, though it's neither limited to that use, nor does it readily bundle image converters/compressors even though that sure has always been a plausible use case for SGML-based pipelines.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: