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