forked from tangled.org/core
Monorepo for Tangled — https://tangled.org

appview: blob: fix weird bg color issue

anirudh.fi ac3555a1 ded0d02a

verified
Changed files
+43 -15
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",
+
}
+1 -2
appview/pages/pages.go
···
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),
+1 -12
appview/pages/templates/repo/blob.html
···
</p>
{{ else }}
<div class="overflow-auto relative">
-
{{ range $idx, $line := $lines }}
-
{{ $linenr := add $idx 1 }}
-
<div class="flex">
-
<a href="#L{{ $linenr }}" id="L{{ $linenr }}" class="no-underline peer">
-
<span class="{{ $code_number_style }}"
-
style="min-width: {{ $tot_chars }}ch;">
-
{{ $linenr }}
-
</span>
-
</a>
-
<div class="whitespace-pre peer-target:bg-yellow-200 dark:peer-target:bg-yellow-900">{{ $line | escapeHtml }}</div>
-
</div>
-
{{ end }}
+
<div class="whitespace-pre peer-target:bg-yellow-200 dark:peer-target:bg-yellow-900">{{ $.Contents | escapeHtml }}</div>
</div>
{{ end }}
{{ end }}
+1 -1
tailwind.config.js
···
const colors = require("tailwindcss/colors");
module.exports = {
-
content: ["./appview/pages/templates/**/*.html"],
+
content: ["./appview/pages/templates/**/*.html", "./appview/pages/chroma.go"],
darkMode: "media",
theme: {
container: {