diff --git a/appview/pages/chroma.go b/appview/pages/chroma.go new file mode 100644 index 00000000..a43e34ce --- /dev/null +++ b/appview/pages/chroma.go @@ -0,0 +1,40 @@ +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", +} diff --git a/appview/pages/pages.go b/appview/pages/pages.go index dd5a91b5..17b95322 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -431,13 +431,12 @@ func (p *Pages) RepoBlob(w io.Writer, params RepoBlobParams) error { style := styles.Get("bw") b := style.Builder() b.Add(chroma.LiteralString, "noitalic") - b.Add(chroma.Background, "bg:") style, _ = b.Build() if params.Lines < 5000 { c := params.Contents formatter := chromahtml.New( - chromahtml.InlineCode(true), + chromahtml.InlineCode(false), chromahtml.WithLineNumbers(true), chromahtml.WithLinkableLineNumbers(true, "L"), chromahtml.Standalone(false), diff --git a/appview/pages/templates/repo/blob.html b/appview/pages/templates/repo/blob.html index bf1b648c..071c9052 100644 --- a/appview/pages/templates/repo/blob.html +++ b/appview/pages/templates/repo/blob.html @@ -52,18 +52,7 @@
{{ else }}