mirror of
1
Fork 0
forgejo/modules/templates
KN4CK3R 875b398e5e
Rework markup link rendering () ()
Backport 
Fixes 

This PR refactors the rendering of markup links. The old code uses
`strings.Replace` to change some urls while the new code uses more
context to decide which link should be generated.

The added tests should ensure the same output for the old and new
behaviour (besides the bug).

We may need to refactor the rendering a bit more to make it clear how
the different helper methods render the input string. There are lots of
options (resolve links / images / mentions / git hashes / emojis / ...)
but you don't really know what helper uses which options. For example,
we currently support images in the user description which should not be
allowed I think:

<details>
  <summary>Profile</summary>

https://try.gitea.io/KN4CK3R

![grafik](https://github.com/go-gitea/gitea/assets/1666336/109ae422-496d-4200-b52e-b3a528f553e5)

</details>

(cherry picked from commit 022552d5b6)
2024-01-16 14:41:11 +00:00
..
eval Use a general Eval function for expressions in templates. () 2023-04-07 21:25:49 +08:00
scopedtmpl Replace `interface{}` with `any` () 2023-07-04 18:36:08 +00:00
vars Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
base.go Replace `util.SliceXxx` with `slices.Xxx` () 2023-09-07 09:37:47 +00:00
dynamic.go Use a general approach to access custom/static/builtin assets () 2023-04-12 18:16:45 +08:00
helper.go Rework markup link rendering () () 2024-01-16 14:41:11 +00:00
helper_test.go Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
htmlrenderer.go Start using template context function () 2023-08-08 01:22:47 +00:00
htmlrenderer_test.go Show friendly 500 error page to users and developers () 2023-04-14 13:19:11 +08:00
mailer.go Improve RunMode / dev mode () 2023-05-25 03:47:30 +00:00
static.go Use a general approach to access custom/static/builtin assets () 2023-04-12 18:16:45 +08:00
templates_bindata.go Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
util_avatar.go Use template context function for avatar rendering () 2023-08-10 11:19:39 +08:00
util_dict.go Use `Set[Type]` instead of `map[Type]bool/struct{}`. () 2023-08-30 06:55:25 +00:00
util_json.go Improve template helper () 2023-04-29 08:02:29 -04:00
util_misc.go Improve feed icons and feed merge text color () () 2023-10-21 12:29:06 +02:00
util_render.go Rework markup link rendering () () 2024-01-16 14:41:11 +00:00
util_render_test.go Rework markup link rendering () () 2024-01-16 14:41:11 +00:00
util_slice.go Improve template helper functions: string/slice () 2023-04-22 14:16:22 -04:00
util_string.go Refactor `og:description` to limit the max length () 2023-09-03 01:43:29 +00:00
util_test.go Improve template helper functions: string/slice () 2023-04-22 14:16:22 -04:00