[bugfix] Fix indentation on multi-line alt text in web view (#4149)

This pull request closes https://codeberg.org/superseriousbusiness/gotosocial/issues/3403 by searching for alt or title attributes in HTML, looking for the shortest indent (if any) at the start of multiline content of said attributes, and remove that shortest indent from each line. This is a bit more fiddly than the "easy" way of doing it, but it has the advantage that it preserves user-added indents at the start of lines of alt text.

Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4149
Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Co-committed-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
tobi 2025-05-07 11:48:21 +00:00 committed by kim
commit 1f0c261fd2
3 changed files with 167 additions and 39 deletions

View file

@ -79,7 +79,7 @@ image/webp
{{- include "page_header.tmpl" . | indent 3 }}
</header>
<div class="page-content">
{{- include .pageContent . | indent 3 | outdentPre }}
{{- include .pageContent . | indent 3 | outdentPreformatted }}
</div>
<footer class="page-footer">
{{- include "page_footer.tmpl" . | indent 3 }}