mirror of
https://github.com/go-gitea/gitea
synced 2024-12-24 16:34:44 +01:00
af7ffaa279
* Server-side syntax hilighting for all code This PR does a few things: * Remove all traces of highlight.js * Use chroma library to provide fast syntax hilighting directly on the server * Provide syntax hilighting for diffs * Re-style both unified and split diffs views * Add custom syntax hilighting styling for both regular and arc-green Fixes #7729 Fixes #10157 Fixes #11825 Fixes #7728 Fixes #3872 Fixes #3682 And perhaps gets closer to #9553 * fix line marker * fix repo search * Fix single line select * properly load settings * npm uninstall highlight.js * review suggestion * code review * forgot to call function * fix test * Apply suggestions from code review suggestions from @silverwind thanks Co-authored-by: silverwind <me@silverwind.io> * code review * copy/paste error * Use const for highlight size limit * Update web_src/less/_repository.less Co-authored-by: Lauris BH <lauris@nix.lv> * update size limit to 1MB and other styling tweaks * fix highlighting for certain diff sections * fix test * add worker back as suggested Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lauris BH <lauris@nix.lv>
48 lines
2.6 KiB
Go
Vendored
48 lines
2.6 KiB
Go
Vendored
package b
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
)
|
|
|
|
// Blitzbasic lexer.
|
|
var Blitzbasic = internal.Register(MustNewLexer(
|
|
&Config{
|
|
Name: "BlitzBasic",
|
|
Aliases: []string{"blitzbasic", "b3d", "bplus"},
|
|
Filenames: []string{"*.bb", "*.decls"},
|
|
MimeTypes: []string{"text/x-bb"},
|
|
CaseInsensitive: true,
|
|
},
|
|
Rules{
|
|
"root": {
|
|
{`[ \t]+`, Text, nil},
|
|
{`;.*?\n`, CommentSingle, nil},
|
|
{`"`, LiteralStringDouble, Push("string")},
|
|
{`[0-9]+\.[0-9]*(?!\.)`, LiteralNumberFloat, nil},
|
|
{`\.[0-9]+(?!\.)`, LiteralNumberFloat, nil},
|
|
{`[0-9]+`, LiteralNumberInteger, nil},
|
|
{`\$[0-9a-f]+`, LiteralNumberHex, nil},
|
|
{`\%[10]+`, LiteralNumberBin, nil},
|
|
{Words(`\b`, `\b`, `Shl`, `Shr`, `Sar`, `Mod`, `Or`, `And`, `Not`, `Abs`, `Sgn`, `Handle`, `Int`, `Float`, `Str`, `First`, `Last`, `Before`, `After`), Operator, nil},
|
|
{`([+\-*/~=<>^])`, Operator, nil},
|
|
{`[(),:\[\]\\]`, Punctuation, nil},
|
|
{`\.([ \t]*)([a-z]\w*)`, NameLabel, nil},
|
|
{`\b(New)\b([ \t]+)([a-z]\w*)`, ByGroups(KeywordReserved, Text, NameClass), nil},
|
|
{`\b(Gosub|Goto)\b([ \t]+)([a-z]\w*)`, ByGroups(KeywordReserved, Text, NameLabel), nil},
|
|
{`\b(Object)\b([ \t]*)([.])([ \t]*)([a-z]\w*)\b`, ByGroups(Operator, Text, Punctuation, Text, NameClass), nil},
|
|
{`\b([a-z]\w*)(?:([ \t]*)(@{1,2}|[#$%])|([ \t]*)([.])([ \t]*)(?:([a-z]\w*)))?\b([ \t]*)(\()`, ByGroups(NameFunction, Text, KeywordType, Text, Punctuation, Text, NameClass, Text, Punctuation), nil},
|
|
{`\b(Function)\b([ \t]+)([a-z]\w*)(?:([ \t]*)(@{1,2}|[#$%])|([ \t]*)([.])([ \t]*)(?:([a-z]\w*)))?`, ByGroups(KeywordReserved, Text, NameFunction, Text, KeywordType, Text, Punctuation, Text, NameClass), nil},
|
|
{`\b(Type)([ \t]+)([a-z]\w*)`, ByGroups(KeywordReserved, Text, NameClass), nil},
|
|
{`\b(Pi|True|False|Null)\b`, KeywordConstant, nil},
|
|
{`\b(Local|Global|Const|Field|Dim)\b`, KeywordDeclaration, nil},
|
|
{Words(`\b`, `\b`, `End`, `Return`, `Exit`, `Chr`, `Len`, `Asc`, `New`, `Delete`, `Insert`, `Include`, `Function`, `Type`, `If`, `Then`, `Else`, `ElseIf`, `EndIf`, `For`, `To`, `Next`, `Step`, `Each`, `While`, `Wend`, `Repeat`, `Until`, `Forever`, `Select`, `Case`, `Default`, `Goto`, `Gosub`, `Data`, `Read`, `Restore`), KeywordReserved, nil},
|
|
{`([a-z]\w*)(?:([ \t]*)(@{1,2}|[#$%])|([ \t]*)([.])([ \t]*)(?:([a-z]\w*)))?`, ByGroups(NameVariable, Text, KeywordType, Text, Punctuation, Text, NameClass), nil},
|
|
},
|
|
"string": {
|
|
{`""`, LiteralStringDouble, nil},
|
|
{`"C?`, LiteralStringDouble, Pop(1)},
|
|
{`[^"]+`, LiteralStringDouble, nil},
|
|
},
|
|
},
|
|
))
|