Feature summary and use cases same as {T334372}. There was an objection to using that task to discuss a Scribunto solution, so creating a dedicated task.
There's a benefit to doing this through Lua, addressing the following shortcomings of the [[https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1043323/|proposed implementation in core]]:
* It uses an `<svg>` tag in wikitext which mimics the HTML `<svg>`, but actually outputs an `<img>`, which is slightly confusing.
* There's some interest in building an SVG sanitizer (T334953) and emitting `<svg>` tags directly to wikitext (see T334372#9708574 and other comments), so the SVG-as-image feature probably shouldn't reserve the `<svg>` markup.
* There is no natural way to declare attributes for the <img> element. The width and height are set to values passed as <svg> attributes. For class, `img-class` attribute of <svg> is awkwardly used. Other attributes of `<img>` like `alt=` could also be useful. Lua can do this more cleanly (think `svg:setAttribute(...)` and `svg:setImgAttribute(...)`)
* The full text of the `<svg>` tag contributes to PEIS, which could make the feature unfeasible for complex SVGs. A Lua implementation will generate the image tag and replace it with a strip item. Thus, it contributes almost nothing to PEIS. Length of SVGs will only be limited by the unstrip post-expand size of 5 MB and revision size of 2 MB.