...

Source file src/github.com/alecthomas/chroma/v2/lexers/myghty.go

Documentation: github.com/alecthomas/chroma/v2/lexers

     1  package lexers
     2  
     3  import (
     4  	. "github.com/alecthomas/chroma/v2" // nolint
     5  )
     6  
     7  // Myghty lexer.
     8  var Myghty = Register(MustNewLexer(
     9  	&Config{
    10  		Name:      "Myghty",
    11  		Aliases:   []string{"myghty"},
    12  		Filenames: []string{"*.myt", "autodelegate"},
    13  		MimeTypes: []string{"application/x-myghty"},
    14  	},
    15  	myghtyRules,
    16  ))
    17  
    18  func myghtyRules() Rules {
    19  	return Rules{
    20  		"root": {
    21  			{`\s+`, Text, nil},
    22  			{`(<%(?:def|method))(\s*)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, Text, NameFunction, NameTag, UsingSelf("root"), NameTag), nil},
    23  			{`(<%\w+)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, NameFunction, NameTag, Using("Python2"), NameTag), nil},
    24  			{`(<&[^|])(.*?)(,.*?)?(&>)`, ByGroups(NameTag, NameFunction, Using("Python2"), NameTag), nil},
    25  			{`(<&\|)(.*?)(,.*?)?(&>)(?s)`, ByGroups(NameTag, NameFunction, Using("Python2"), NameTag), nil},
    26  			{`</&>`, NameTag, nil},
    27  			{`(<%!?)(.*?)(%>)(?s)`, ByGroups(NameTag, Using("Python2"), NameTag), nil},
    28  			{`(?<=^)#[^\n]*(\n|\Z)`, Comment, nil},
    29  			{`(?<=^)(%)([^\n]*)(\n|\Z)`, ByGroups(NameTag, Using("Python2"), Other), nil},
    30  			{`(?sx)
    31                   (.+?)               # anything, followed by:
    32                   (?:
    33                    (?<=\n)(?=[%#]) |  # an eval or comment line
    34                    (?=</?[%&]) |      # a substitution or block or
    35                                       # call start or end
    36                                       # - don't consume
    37                    (\\\n) |           # an escaped newline
    38                    \Z                 # end of string
    39                   )`, ByGroups(Other, Operator), nil},
    40  		},
    41  	}
    42  }
    43  

View as plain text