···
···
21
+
"github.com/alecthomas/chroma/v2"
22
+
chromahtml "github.com/alecthomas/chroma/v2/formatters/html"
23
+
"github.com/alecthomas/chroma/v2/lexers"
24
+
"github.com/alecthomas/chroma/v2/styles"
"github.com/bluesky-social/indigo/atproto/syntax"
"github.com/dustin/go-humanize"
"github.com/go-enry/go-enry/v2"
···
sanitized := p.rctx.SanitizeDescription(htmlString)
return template.HTML(sanitized)
254
+
"readme": func(text string) template.HTML {
255
+
p.rctx.RendererType = markup.RendererTypeRepoMarkdown
256
+
htmlString := p.rctx.RenderMarkdown(text)
257
+
sanitized := p.rctx.SanitizeDefault(htmlString)
258
+
return template.HTML(sanitized)
260
+
"code": func(content, path string) string {
261
+
var style *chroma.Style = styles.Get("catpuccin-latte")
262
+
formatter := chromahtml.New(
263
+
chromahtml.InlineCode(false),
264
+
chromahtml.WithLineNumbers(true),
265
+
chromahtml.WithLinkableLineNumbers(true, "L"),
266
+
chromahtml.Standalone(false),
267
+
chromahtml.WithClasses(true),
270
+
lexer := lexers.Get(filepath.Base(path))
272
+
lexer = lexers.Fallback
275
+
iterator, err := lexer.Tokenise(nil, content)
277
+
p.logger.Error("chroma tokenize", "err", "err")
281
+
var code bytes.Buffer
282
+
err = formatter.Format(&code, style, iterator)
284
+
p.logger.Error("chroma format", "err", "err")
288
+
return code.String()
"trimUriScheme": func(text string) string {
text = strings.TrimPrefix(text, "https://")
text = strings.TrimPrefix(text, "http://")