+10
-4
appview/pages/funcmap.go
+10
-4
appview/pages/funcmap.go
···
19
19
20
20
"github.com/dustin/go-humanize"
21
21
"github.com/go-enry/go-enry/v2"
22
-
"github.com/microcosm-cc/bluemonday"
23
22
"tangled.sh/tangled.sh/core/appview/filetree"
24
23
"tangled.sh/tangled.sh/core/appview/pages/markup"
25
24
)
···
207
206
}
208
207
return v.Slice(0, min(n, v.Len())).Interface()
209
208
},
210
-
211
209
"markdown": func(text string) template.HTML {
212
-
rctx := &markup.RenderContext{RendererType: markup.RendererTypeDefault}
213
-
return template.HTML(bluemonday.UGCPolicy().Sanitize(rctx.RenderMarkdown(text)))
210
+
p.rctx.RendererType = markup.RendererTypeDefault
211
+
htmlString := p.rctx.RenderMarkdown(text)
212
+
sanitized := p.rctx.SanitizeDefault(htmlString)
213
+
return template.HTML(sanitized)
214
+
},
215
+
"description": func(text string) template.HTML {
216
+
p.rctx.RendererType = markup.RendererTypeDefault
217
+
htmlString := p.rctx.RenderMarkdown(text)
218
+
sanitized := p.rctx.SanitizeDescription(htmlString)
219
+
return template.HTML(sanitized)
214
220
},
215
221
"isNil": func(t any) bool {
216
222
// returns false for other "zero" values
+4
appview/pages/markup/markdown.go
+4
appview/pages/markup/markdown.go
···
164
164
return rctx.Sanitizer.defaultPolicy.Sanitize(html)
165
165
}
166
166
167
+
func (rctx *RenderContext) SanitizeDescription(html string) string {
168
+
return rctx.Sanitizer.descriptionPolicy.Sanitize(html)
169
+
}
170
+
167
171
type MarkdownTransformer struct {
168
172
rctx *RenderContext
169
173
}
+20
-2
appview/pages/markup/sanitizer.go
+20
-2
appview/pages/markup/sanitizer.go
···
11
11
)
12
12
13
13
type Sanitizer struct {
14
-
defaultPolicy *bluemonday.Policy
14
+
defaultPolicy *bluemonday.Policy
15
+
descriptionPolicy *bluemonday.Policy
15
16
}
16
17
17
18
func NewSanitizer() Sanitizer {
18
19
return Sanitizer{
19
-
defaultPolicy: defaultPolicy(),
20
+
defaultPolicy: defaultPolicy(),
21
+
descriptionPolicy: descriptionPolicy(),
20
22
}
21
23
}
22
24
···
90
92
91
93
return policy
92
94
}
95
+
96
+
func descriptionPolicy() *bluemonday.Policy {
97
+
policy := bluemonday.NewPolicy()
98
+
policy.AllowStandardURLs()
99
+
100
+
// allow italics and bold.
101
+
policy.AllowElements("i", "b", "em", "strong")
102
+
103
+
// allow code.
104
+
policy.AllowElements("code")
105
+
106
+
// allow links
107
+
policy.AllowAttrs("href", "target", "rel").OnElements("a")
108
+
109
+
return policy
110
+
}
+1
-1
appview/pages/templates/repo/issues/issue.html
+1
-1
appview/pages/templates/repo/issues/issue.html
+1
-1
appview/pages/templates/repo/issues/issues.html
+1
-1
appview/pages/templates/repo/issues/issues.html
+1
-1
appview/pages/templates/repo/pulls/fragments/summarizedPullHeader.html
+1
-1
appview/pages/templates/repo/pulls/fragments/summarizedPullHeader.html
+1
-1
appview/pages/templates/repo/pulls/pull.html
+1
-1
appview/pages/templates/repo/pulls/pull.html
···
149
149
{{ end }}
150
150
</div>
151
151
<div class="flex items-center">
152
-
<span>{{ .Title }}</span>
152
+
<span>{{ .Title | description }}</span>
153
153
{{ if gt (len .Body) 0 }}
154
154
<button
155
155
class="py-1/2 px-1 mx-2 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600"