diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-11-24 16:18:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-24 16:18:57 +0800 |
commit | 633785a5f3fe00789a6cba7cc0db1333de1e9c52 (patch) | |
tree | 2a2703ee9ed41c9caa508bd72c3fb5b52716af16 /modules/markup/html_codepreview_test.go | |
parent | fa175c16949f09757ae85db6697cec327c44cba9 (diff) | |
download | gitea-633785a5f3fe00789a6cba7cc0db1333de1e9c52.tar.gz gitea-633785a5f3fe00789a6cba7cc0db1333de1e9c52.zip |
Refactor markup render system (#32612)
This PR removes (almost) all path tricks, and introduces "renderhelper"
package.
Now we can clearly see the rendering behaviors for comment/file/wiki,
more details are in "renderhelper" tests.
Fix #31411 , fix #18592, fix #25632 and maybe more problems. (ps: fix
#32608 by the way)
Diffstat (limited to 'modules/markup/html_codepreview_test.go')
-rw-r--r-- | modules/markup/html_codepreview_test.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/markup/html_codepreview_test.go b/modules/markup/html_codepreview_test.go index 7c0db59d06..3d99348ef1 100644 --- a/modules/markup/html_codepreview_test.go +++ b/modules/markup/html_codepreview_test.go @@ -16,16 +16,16 @@ import ( ) func TestRenderCodePreview(t *testing.T) { - markup.Init(&markup.ProcessorHelper{ - RenderRepoFileCodePreview: func(ctx context.Context, opts markup.RenderCodePreviewOptions) (template.HTML, error) { + markup.Init(&markup.RenderHelperFuncs{ + RenderRepoFileCodePreview: func(ctx context.Context, options markup.RenderCodePreviewOptions) (template.HTML, error) { return "<div>code preview</div>", nil }, }) test := func(input, expected string) { - buffer, err := markup.RenderString(markup.NewRenderContext(context.Background()).WithMarkupType(markdown.MarkupName), input) + buffer, err := markup.RenderString(markup.NewTestRenderContext().WithMarkupType(markdown.MarkupName), input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) } test("http://localhost:3000/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20", "<p><div>code preview</div></p>") - test("http://other/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20", `<p><a href="http://other/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20" data-markdown-generated-content="" rel="nofollow">http://other/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20</a></p>`) + test("http://other/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20", `<p><a href="http://other/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20" rel="nofollow">http://other/owner/repo/src/commit/0123456789/foo/bar.md#L10-L20</a></p>`) } |