package lexers import ( . "github.com/alecthomas/chroma" // nolint ) // Genshi Text lexer. var GenshiText = Register(MustNewLexer( &Config{ Name: "Genshi Text", Aliases: []string{"genshitext"}, Filenames: []string{}, MimeTypes: []string{"application/x-genshi-text", "text/x-genshi"}, }, Rules{ "root": { {`[^#$\s]+`, Other, nil}, {`^(\s*)(##.*)$`, ByGroups(Text, Comment), nil}, {`^(\s*)(#)`, ByGroups(Text, CommentPreproc), Push("directive")}, Include("variable"), {`[#$\s]`, Other, nil}, }, "directive": { {`\n`, Text, Pop(1)}, {`(?:def|for|if)\s+.*`, Using(Python, nil), Pop(1)}, {`(choose|when|with)([^\S\n]+)(.*)`, ByGroups(Keyword, Text, Using(Python, nil)), Pop(1)}, {`(choose|otherwise)\b`, Keyword, Pop(1)}, {`(end\w*)([^\S\n]*)(.*)`, ByGroups(Keyword, Text, Comment), Pop(1)}, }, "variable": { {`(?)`, ByGroups(CommentPreproc, Using(Python, nil), CommentPreproc), nil}, {`<\s*(script|style)\s*.*?>.*?<\s*/\1\s*>`, Other, nil}, {`<\s*py:[a-zA-Z0-9]+`, NameTag, Push("pytag")}, {`<\s*[a-zA-Z0-9:.]+`, NameTag, Push("tag")}, Include("variable"), {`[<$]`, Other, nil}, }, "pytag": { {`\s+`, Text, nil}, {`[\w:-]+\s*=`, NameAttribute, Push("pyattr")}, {`/?\s*>`, NameTag, Pop(1)}, }, "pyattr": { {`(")(.*?)(")`, ByGroups(LiteralString, Using(Python, nil), LiteralString), Pop(1)}, {`(')(.*?)(')`, ByGroups(LiteralString, Using(Python, nil), LiteralString), Pop(1)}, {`[^\s>]+`, LiteralString, Pop(1)}, }, "tag": { {`\s+`, Text, nil}, {`py:[\w-]+\s*=`, NameAttribute, Push("pyattr")}, {`[\w:-]+\s*=`, NameAttribute, Push("attr")}, {`/?\s*>`, NameTag, Pop(1)}, }, "attr": { {`"`, LiteralString, Push("attr-dstring")}, {`'`, LiteralString, Push("attr-sstring")}, {`[^\s>]*`, LiteralString, Pop(1)}, }, "attr-dstring": { {`"`, LiteralString, Pop(1)}, Include("strings"), {`'`, LiteralString, nil}, }, "attr-sstring": { {`'`, LiteralString, Pop(1)}, Include("strings"), {`'`, LiteralString, nil}, }, "strings": { {`[^"'$]+`, LiteralString, nil}, Include("variable"), }, "variable": { {`(?