tangled
alpha
login
or
join now
regnault.dev
/
core
forked from
tangled.org/core
Monorepo for Tangled
0
fork
atom
overview
issues
pulls
pipelines
appview: render markdown in issues
anirudh.fi
10 months ago
a4ae41d9
45de8d7f
+35
-2
5 changed files
expand all
collapse all
unified
split
appview
pages
funcmap.go
markdown.go
templates
repo
issues
issue.html
go.mod
go.sum
+3
appview/pages/funcmap.go
···
103
103
}
104
104
return v.Slice(start, end).Interface()
105
105
},
106
106
+
"markdown": func(text string) template.HTML {
107
107
+
return template.HTML(renderMarkdown(text))
108
108
+
},
106
109
}
107
110
}
+28
appview/pages/markdown.go
···
1
1
+
package pages
2
2
+
3
3
+
import (
4
4
+
"bytes"
5
5
+
6
6
+
"github.com/yuin/goldmark"
7
7
+
"github.com/yuin/goldmark/extension"
8
8
+
"github.com/yuin/goldmark/parser"
9
9
+
"github.com/yuin/goldmark/renderer/html"
10
10
+
)
11
11
+
12
12
+
func renderMarkdown(source string) string {
13
13
+
md := goldmark.New(
14
14
+
goldmark.WithExtensions(extension.GFM),
15
15
+
goldmark.WithParserOptions(
16
16
+
parser.WithAutoHeadingID(),
17
17
+
),
18
18
+
goldmark.WithRendererOptions(
19
19
+
html.WithHardWraps(),
20
20
+
html.WithXHTML(),
21
21
+
),
22
22
+
)
23
23
+
var buf bytes.Buffer
24
24
+
if err := md.Convert([]byte(source), &buf); err != nil {
25
25
+
return source
26
26
+
}
27
27
+
return buf.String()
28
28
+
}
+2
-2
appview/pages/templates/repo/issues/issue.html
···
42
42
43
43
{{ if .Issue.Body }}
44
44
<article id="body" class="mt-8">
45
45
-
{{ .Issue.Body | escapeHtml }}
45
45
+
{{ .Issue.Body | markdown }}
46
46
</article>
47
47
{{ end }}
48
48
</section>
···
83
83
</a>
84
84
</div>
85
85
<div class="">
86
86
-
{{ nl2br .Body }}
86
86
+
{{ .Body | markdown }}
87
87
</div>
88
88
</div>
89
89
{{ end }}
+1
go.mod
···
24
24
github.com/russross/blackfriday/v2 v2.1.0
25
25
github.com/sethvargo/go-envconfig v1.1.0
26
26
github.com/whyrusleeping/cbor-gen v0.2.1-0.20241030202151-b7a6831be65e
27
27
+
github.com/yuin/goldmark v1.4.13
27
28
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028
28
29
)
29
30
+1
go.sum
···
263
263
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
264
264
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
265
265
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
266
266
+
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
266
267
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
267
268
gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b h1:CzigHMRySiX3drau9C6Q5CAbNIApmLdat5jPMqChvDA=
268
269
gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b/go.mod h1:/y/V339mxv2sZmYYR64O07VuCpdNZqCTwO8ZcouTMI8=