[FEAT] Adds x-mode-only anchor styles to display images based if the theme is light or dark mode. (#3985)

Adds a feature similar to this https://github.blog/changelog/2021-11-24-specify-theme-context-for-images-in-markdown/ , by adding styles to elements which `src` or `href` attribute ends with `#light-mode-only` or `#dark-mode-only`. To improve compability, the github variants with the `gh-` prefix are also contained.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3985
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Mai-Lapyst <mai-lapyst@noreply.codeberg.org>
Co-committed-by: Mai-Lapyst <mai-lapyst@noreply.codeberg.org>
This commit is contained in:
Mai-Lapyst 2024-06-09 10:50:53 +00:00 committed by 0ko
parent 96f661e821
commit 0a7767eaaa
12 changed files with 51 additions and 4 deletions

View file

@ -39,7 +39,7 @@ func TestAPIListRepoComments(t *testing.T) {
var apiComments []*api.Comment
DecodeJSON(t, resp, &apiComments)
assert.Len(t, apiComments, 2)
assert.Len(t, apiComments, 3)
for _, apiComment := range apiComments {
c := &issues_model.Comment{ID: apiComment.ID}
unittest.AssertExistsAndLoadBean(t, c,
@ -65,7 +65,7 @@ func TestAPIListRepoComments(t *testing.T) {
req = NewRequest(t, "GET", link.String())
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiComments)
assert.Len(t, apiComments, 1)
assert.Len(t, apiComments, 2)
assert.EqualValues(t, 3, apiComments[0].ID)
}