From 21783a5752f518e579d8fe48b33504a16674ee17 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 18 Jun 2024 11:09:20 +0800 Subject: Fix rendered wiki page link (#31398) Fix #31395 --- modules/markup/markdown/markdown_test.go | 10 +++++----- modules/markup/markdown/transform_link.go | 29 ++--------------------------- 2 files changed, 7 insertions(+), 32 deletions(-) (limited to 'modules/markup/markdown') diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index 8c41ec12e3..9a8c39df0a 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -635,7 +635,7 @@ mail@domain.com https://example.com/file.bin
local link
remote link
-local link
+local link
remote link
local image
local image
@@ -691,7 +691,7 @@ space

https://example.com/file.bin
local link
remote link
-local link
+local link
remote link
local image
local image
@@ -749,7 +749,7 @@ space

https://example.com/file.bin
local link
remote link
-local link
+local link
remote link
local image
local image
@@ -866,7 +866,7 @@ space

Expected: `

space @mention-user
/just/a/path.bin
https://example.com/file.bin
-local link
+local link
remote link
local link
remote link
@@ -984,7 +984,7 @@ space

for i, c := range cases { result, err := markdown.RenderString(&markup.RenderContext{Ctx: context.Background(), Links: c.Links, IsWiki: c.IsWiki}, input) assert.NoError(t, err, "Unexpected error in testcase: %v", i) - assert.Equal(t, template.HTML(c.Expected), result, "Unexpected result in testcase %v", i) + assert.Equal(t, c.Expected, string(result), "Unexpected result in testcase %v", i) } } diff --git a/modules/markup/markdown/transform_link.go b/modules/markup/markdown/transform_link.go index 527a5dfc44..38fbf693ab 100644 --- a/modules/markup/markdown/transform_link.go +++ b/modules/markup/markdown/transform_link.go @@ -4,38 +4,13 @@ package markdown import ( - "path/filepath" - "code.gitea.io/gitea/modules/markup" - giteautil "code.gitea.io/gitea/modules/util" "github.com/yuin/goldmark/ast" ) func (g *ASTTransformer) transformLink(ctx *markup.RenderContext, v *ast.Link) { - // Links need their href to munged to be a real value - link := v.Destination - isAnchorFragment := len(link) > 0 && link[0] == '#' - if !isAnchorFragment && !markup.IsFullURLBytes(link) { - base := ctx.Links.Base - if ctx.IsWiki { - if filepath.Ext(string(link)) == "" { - // This link doesn't have a file extension - assume a regular wiki link - base = ctx.Links.WikiLink() - } else if markup.Type(string(link)) != "" { - // If it's a file type we can render, use a regular wiki link - base = ctx.Links.WikiLink() - } else { - // Otherwise, use a raw link instead - base = ctx.Links.WikiRawLink() - } - } else if ctx.Links.HasBranchInfo() { - base = ctx.Links.SrcLink() - } - link = []byte(giteautil.URLJoin(base, string(link))) - } - if isAnchorFragment { - link = []byte("#user-content-" + string(link)[1:]) + if link, resolved := markup.ResolveLink(ctx, string(v.Destination), "#user-content-"); resolved { + v.Destination = []byte(link) } - v.Destination = link } -- cgit v1.2.3 e/xmlgraphics-fopwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/pdf/PDFPages.java
blob: 3c099dacb2507eb1a7517efc1a043da235c1869d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130