tangled
alpha
login
or
join now
julien.rbrt.fr
/
tangled-core
forked from
tangled.org/core
0
fork
atom
Monorepo for Tangled — https://tangled.org
0
fork
atom
overview
issues
pulls
pipelines
appview: pages: embed syntax highlighting for code
anirudh.fi
10 months ago
57d497a0
f98a46a5
verified
This commit was signed with the committer's
known signature
.
anirudh.fi
SSH Key Fingerprint:
SHA256:cz35vdbiWEzCNEfuL9fMC2JVIhtXavXBHrRjv8gxpAk=
+3
-42
3 changed files
expand all
collapse all
unified
split
appview
pages
chroma.go
pages.go
templates
repo
blob.html
-40
appview/pages/chroma.go
···
1
1
-
package pages
2
2
-
3
3
-
import "github.com/alecthomas/chroma/v2"
4
4
-
5
5
-
var tangledTheme map[chroma.TokenType]string = map[chroma.TokenType]string{
6
6
-
// Keywords
7
7
-
chroma.Keyword: "text-blue-400",
8
8
-
chroma.KeywordConstant: "text-indigo-400",
9
9
-
chroma.KeywordDeclaration: "text-purple-400",
10
10
-
chroma.KeywordNamespace: "text-teal-400",
11
11
-
chroma.KeywordReserved: "text-pink-400",
12
12
-
13
13
-
// Names
14
14
-
chroma.Name: "text-gray-700",
15
15
-
chroma.NameFunction: "text-green-500",
16
16
-
chroma.NameClass: "text-orange-400",
17
17
-
chroma.NameNamespace: "text-cyan-500",
18
18
-
chroma.NameVariable: "text-red-400",
19
19
-
chroma.NameBuiltin: "text-yellow-500",
20
20
-
21
21
-
// Literals
22
22
-
chroma.LiteralString: "text-emerald-500 ",
23
23
-
chroma.LiteralStringChar: "text-lime-500",
24
24
-
chroma.LiteralNumber: "text-rose-400",
25
25
-
chroma.LiteralNumberFloat: "text-amber-500",
26
26
-
27
27
-
// Operators
28
28
-
chroma.Operator: "text-blue-500",
29
29
-
chroma.OperatorWord: "text-indigo-500",
30
30
-
31
31
-
// Comments
32
32
-
chroma.Comment: "text-gray-500 italic",
33
33
-
chroma.CommentSingle: "text-gray-400 italic",
34
34
-
35
35
-
// Generic
36
36
-
chroma.GenericError: "text-red-600",
37
37
-
chroma.GenericHeading: "text-purple-500 font-bold",
38
38
-
chroma.GenericDeleted: "text-red-400 line-through",
39
39
-
chroma.GenericInserted: "text-green-400 underline",
40
40
-
}
+2
-2
appview/pages/pages.go
···
497
497
}
498
498
499
499
func (p *Pages) RepoBlob(w io.Writer, params RepoBlobParams) error {
500
500
-
style := styles.Get("bw")
500
500
+
var style *chroma.Style = styles.Get("catpuccin-latte")
501
501
b := style.Builder()
502
502
-
b.Add(chroma.LiteralString, "noitalic")
503
502
style, _ = b.Build()
504
503
505
504
if params.ShowRendered {
···
516
515
chromahtml.WithLineNumbers(true),
517
516
chromahtml.WithLinkableLineNumbers(true, "L"),
518
517
chromahtml.Standalone(false),
518
518
+
chromahtml.WithClasses(true),
519
519
)
520
520
521
521
lexer := lexers.Get(filepath.Base(params.Path))
+1
appview/pages/templates/repo/blob.html
···
59
59
</p>
60
60
{{ else }}
61
61
<div class="overflow-auto relative">
62
62
+
<link rel="stylesheet" href="/static/syntax.css">
62
63
{{ if .ShowRendered }}
63
64
<div id="blob-contents" class="prose dark:prose-invert">{{ .RenderedContents }}</div>
64
65
{{ else }}