mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-26 10:47:04 -06:00
Render user mentions like GitHub, semibold in the surrounding text color, and highlight mentions of the signed-in user in yellow so they stand out in long threads. The renderer adds `user-mention` and `current-user` classes, the styling is pure CSS. CODEOWNERS and OAuth creator links use the same class, team mentions are unchanged. | Before | After | | --- | --- | | <img width="291" height="29" alt="before" src="https://github.com/user-attachments/assets/6c451e7a-dfce-4e95-a386-f9aa9d28c721" /> | <img width="291" height="29" alt="after" src="https://github.com/user-attachments/assets/6b137c71-4692-46f2-adf8-d77ee87f3077" /> | Assisted-by: Claude Code:claude-opus-5-5
37 lines
1002 B
Go
37 lines
1002 B
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package renderhelper
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dev/modules/markup/markdown"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestSimpleDocument(t *testing.T) {
|
|
rctx := NewRenderContextSimpleDocument(t.Context(), "/base").WithMarkupType(markdown.MarkupName)
|
|
rendered, err := testRenderString(rctx, `
|
|
65f1bf27bc3bf70f64657658635e66094edbcb4d
|
|
#1
|
|
@user2
|
|
|
|
[/test](/test)
|
|
[./test](./test)
|
|

|
|

|
|
`)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t,
|
|
`<p>65f1bf27bc3bf70f64657658635e66094edbcb4d
|
|
#1
|
|
<a href="/user2" class="user-mention" rel="nofollow">@user2</a></p>
|
|
<p><a href="/base/test" rel="nofollow">/test</a>
|
|
<a href="/base/test" rel="nofollow">./test</a>
|
|
<a href="/base/image" target="_blank" rel="nofollow noopener"><img src="/base/image" alt="/image"/></a>
|
|
<a href="/base/image" target="_blank" rel="nofollow noopener"><img src="/base/image" alt="./image"/></a></p>
|
|
`, rendered)
|
|
}
|