forgejo/modules
Robert Wolff 14c5462019 fix(ui): reworked file preview placement towards better HTML validity (#9181)
### What?

- fixes HTML nodes placement for inline previews
- (breaking?) disallows file previews in headings (`<h1>`, …), striked out (`<del>`), `<summary>` and other environments
- allows them in `<span>`, `<em>` and `<strong>` environments, but without extra formatting
- allows them in `<div>`, `<li>`, `<th>`, `<td>` and `<details>` (not in `<summary>`) environments following the parent’s formatting
- improves overall HTML validity, but only to the extend of the direct parent nodes (but not a big issue, as modern browsers tend to ignore invalid HTML and still parse it)
- fix #9136

See examples of strangely formatted file previews at https://v13.next.forgejo.org/mahlzahn/test/issues/4.

### How is it implemented?

For links in `<p>`, `<span>`, `<em>` and `<strong>` parent nodes it inserts the file preview and following text as siblings to the **parent** node.
`<em>before LINK after</em>`
→ `<em>before </em>PREVIEW<em> after</em>`

For links in `<div>`, `<li>`, `<th>`, `<td>` and `<details>` parent nodes it inserts the file preview and following text as siblings to the **text** node.
`<div>before LINK after</div>`
→ `<div>before PREVIEW after</div>`

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9181
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Robert Wolff <mahlzahn@posteo.de>
Co-committed-by: Robert Wolff <mahlzahn@posteo.de>
2025-09-15 15:57:52 +02:00
..
actions Update module code.forgejo.org/forgejo/runner/v9 to v11 (forgejo) (#9218) 2025-09-10 22:02:55 +02:00
activitypub fix: assorted ActivityPub code only refactors (#8708) 2025-07-28 15:17:29 +02:00
analyze
assetfs fix: follow symlinks for local assets (#8596) 2025-07-22 15:02:47 +02:00
auth chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
avatar chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
base git/commit: re-implement submodules file reader (#8438) 2025-07-15 00:20:00 +02:00
cache chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
card
charset feat: update ambigious characters (#7988) 2025-05-29 10:00:12 +02:00
container chore: do not require empty fixtures to clean tables (#8353) 2025-06-30 23:04:16 +02:00
csv Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
emoji chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
eventsource
forgefed Sent user activities to distant federated server (#8792) 2025-08-06 16:16:13 +02:00
generate chore(sec): unify usage of crypto/rand.Read (#7453) 2025-04-04 03:31:37 +00:00
git fix: ignore existence of commits for force pushes (#9262) 2025-09-12 07:27:15 +02:00
gitrepo
graceful feat: enable H2C for the HTTP server (#8861) 2025-08-16 21:00:20 +02:00
hcaptcha
highlight Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
hostmatcher
html
httpcache
httplib feat: detect Interlisp sources as text (#8377) 2025-07-02 07:38:46 +02:00
indexer Update module github.com/meilisearch/meilisearch-go to v0.34.0 (forgejo) (#9275) 2025-09-14 13:22:15 +02:00
issue/template chore: replace gopkg.in/yaml.v3 with go.yaml.in/yaml/v3 (#8956) 2025-08-20 15:31:12 +02:00
json
keying feat: migrate action secrets to keying to store them more securely (#8692) 2025-07-29 01:03:36 +02:00
label chore: replace gopkg.in/yaml.v3 with go.yaml.in/yaml/v3 (#8956) 2025-08-20 15:31:12 +02:00
lfs feat: bump the minimum required Git version from 2.0.0 to 2.34.1 (#8328) 2025-06-29 00:44:18 +02:00
log feat(log): better parseable and configurable ssh-logs (#9056) 2025-09-11 18:59:24 +02:00
markup fix(ui): reworked file preview placement towards better HTML validity (#9181) 2025-09-15 15:57:52 +02:00
mcaptcha
metrics
migration chore: replace gopkg.in/yaml.v3 with go.yaml.in/yaml/v3 (#8956) 2025-08-20 15:31:12 +02:00
nosql
optional chore: replace gopkg.in/yaml.v3 with go.yaml.in/yaml/v3 (#8956) 2025-08-20 15:31:12 +02:00
options
packages chore: replace gopkg.in/yaml.v3 with go.yaml.in/yaml/v3 (#8956) 2025-08-20 15:31:12 +02:00
paginator
pprof
private feat(log): better parseable and configurable ssh-logs (#9056) 2025-09-11 18:59:24 +02:00
process Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
proxy
proxyprotocol
public add model viewer for .glb (GLTF) model in file view (#8111) 2025-06-21 14:42:35 +02:00
queue chore: QoL improvements to tests (#7917) 2025-05-21 15:45:56 +02:00
recaptcha
references fix: pull request cross references (#7979) 2025-05-28 14:50:05 +02:00
regexplru Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
repository feat: configurable default units for mirrors (#7902) 2025-06-03 08:12:29 +02:00
secret
session
setting fix: [quota.default].TOTAL config setting supports unit suffixes (#9252) 2025-09-12 00:44:09 +02:00
sitemap
ssh feat(log): better parseable and configurable ssh-logs (#9056) 2025-09-11 18:59:24 +02:00
storage fix: minio initialization can freeze indefinitely if misconfigured (#8897) 2025-08-15 21:03:51 +02:00
structs chore: replace gopkg.in/yaml.v3 with go.yaml.in/yaml/v3 (#8956) 2025-08-20 15:31:12 +02:00
svg
sync
system Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
templates feat: improve custom emojis (#8855) 2025-08-24 16:16:46 +02:00
test Improved signature handling & instance actor (#8275) 2025-07-01 19:49:00 +02:00
testlogger feat: use XORM EngineGroup instead of single Engine connection (#7212) 2025-03-30 11:34:02 +00:00
timeutil Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
translation frontend: generic lazy loader for webcomponents (#8510) 2025-07-23 04:10:50 +02:00
turnstile
typesniffer feat: detect Interlisp sources as text (#8377) 2025-07-02 07:38:46 +02:00
updatechecker
uri
user
util chore: add extra shell escape tests 2025-08-30 08:52:25 +02:00
validation chore: add email blocklist unit test 2025-08-30 09:45:19 +02:00
web feat: make Forgejo Actions server logs less noisy (#7986) 2025-05-29 10:06:30 +02:00
webhook Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
zstd