/usr/share/gocode/src/github.com/alecthomas/chroma/lexers/j/jsx.go is in golang-github-alecthomas-chroma-dev 0.4.0+git20180402.51d250f-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | package j
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
var JSXRules = func() Rules {
rules := JavascriptRules.Clone()
rules["jsx"] = []Rule{
{`(<)([\w_\-]+)`, ByGroups(Punctuation, NameTag), Push("tag")},
{`(<)(/)(\s*)([\w_\-]+)(\s*)(>)`, ByGroups(Punctuation, Punctuation, Text, NameTag, Text, Punctuation), nil},
}
rules["tag"] = []Rule{
{`\s+`, Text, nil},
{`([\w]+\s*)(=)(\s*)`, ByGroups(NameAttribute, Operator, Text), Push("attr")},
{`[{}]+`, Punctuation, nil},
{`[\w\.]+`, NameAttribute, nil},
{`(/?)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation), Pop(1)},
}
rules["attr"] = []Rule{
{`\s+`, Text, nil},
{`".*?"`, String, Pop(1)},
{`'.*?'`, String, Pop(1)},
{`[^\s>]+`, String, Pop(1)},
}
rules["root"] = append([]Rule{Include("jsx")}, rules["root"]...)
return rules
}()
// JSX lexer.
var JSX = internal.Register(MustNewLexer(
&Config{
Name: "JSX",
Aliases: []string{"react"},
Filenames: []string{"*.jsx", "*.react"},
MimeTypes: []string{"text/jsx", "text/typescript-jsx"},
DotAll: true,
},
JSXRules,
))
|