forked from tangled.org/core
this repo has no description

appview: pages: embed syntax highlighting for code

anirudh.fi 57d497a0 f98a46a5

verified
Changed files
+3 -42
appview
pages
templates
repo
-40
appview/pages/chroma.go
···
-
package pages
-
-
import "github.com/alecthomas/chroma/v2"
-
-
var tangledTheme map[chroma.TokenType]string = map[chroma.TokenType]string{
-
// Keywords
-
chroma.Keyword: "text-blue-400",
-
chroma.KeywordConstant: "text-indigo-400",
-
chroma.KeywordDeclaration: "text-purple-400",
-
chroma.KeywordNamespace: "text-teal-400",
-
chroma.KeywordReserved: "text-pink-400",
-
-
// Names
-
chroma.Name: "text-gray-700",
-
chroma.NameFunction: "text-green-500",
-
chroma.NameClass: "text-orange-400",
-
chroma.NameNamespace: "text-cyan-500",
-
chroma.NameVariable: "text-red-400",
-
chroma.NameBuiltin: "text-yellow-500",
-
-
// Literals
-
chroma.LiteralString: "text-emerald-500 ",
-
chroma.LiteralStringChar: "text-lime-500",
-
chroma.LiteralNumber: "text-rose-400",
-
chroma.LiteralNumberFloat: "text-amber-500",
-
-
// Operators
-
chroma.Operator: "text-blue-500",
-
chroma.OperatorWord: "text-indigo-500",
-
-
// Comments
-
chroma.Comment: "text-gray-500 italic",
-
chroma.CommentSingle: "text-gray-400 italic",
-
-
// Generic
-
chroma.GenericError: "text-red-600",
-
chroma.GenericHeading: "text-purple-500 font-bold",
-
chroma.GenericDeleted: "text-red-400 line-through",
-
chroma.GenericInserted: "text-green-400 underline",
-
}
···
+2 -2
appview/pages/pages.go
···
}
func (p *Pages) RepoBlob(w io.Writer, params RepoBlobParams) error {
-
style := styles.Get("bw")
b := style.Builder()
-
b.Add(chroma.LiteralString, "noitalic")
style, _ = b.Build()
if params.ShowRendered {
···
chromahtml.WithLineNumbers(true),
chromahtml.WithLinkableLineNumbers(true, "L"),
chromahtml.Standalone(false),
)
lexer := lexers.Get(filepath.Base(params.Path))
···
}
func (p *Pages) RepoBlob(w io.Writer, params RepoBlobParams) error {
+
var style *chroma.Style = styles.Get("catpuccin-latte")
b := style.Builder()
style, _ = b.Build()
if params.ShowRendered {
···
chromahtml.WithLineNumbers(true),
chromahtml.WithLinkableLineNumbers(true, "L"),
chromahtml.Standalone(false),
+
chromahtml.WithClasses(true),
)
lexer := lexers.Get(filepath.Base(params.Path))
+1
appview/pages/templates/repo/blob.html
···
</p>
{{ else }}
<div class="overflow-auto relative">
{{ if .ShowRendered }}
<div id="blob-contents" class="prose dark:prose-invert">{{ .RenderedContents }}</div>
{{ else }}
···
</p>
{{ else }}
<div class="overflow-auto relative">
+
<link rel="stylesheet" href="/static/syntax.css">
{{ if .ShowRendered }}
<div id="blob-contents" class="prose dark:prose-invert">{{ .RenderedContents }}</div>
{{ else }}