...

Source file src/github.com/alecthomas/chroma/lexers/c/cheetah.go

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

     1  package c
     2  
     3  import (
     4  	. "github.com/alecthomas/chroma" // nolint
     5  	"github.com/alecthomas/chroma/lexers/internal"
     6  	. "github.com/alecthomas/chroma/lexers/p" // nolint
     7  )
     8  
     9  // Cheetah lexer.
    10  var Cheetah = internal.Register(MustNewLazyLexer(
    11  	&Config{
    12  		Name:      "Cheetah",
    13  		Aliases:   []string{"cheetah", "spitfire"},
    14  		Filenames: []string{"*.tmpl", "*.spt"},
    15  		MimeTypes: []string{"application/x-cheetah", "application/x-spitfire"},
    16  	},
    17  	cheetahRules,
    18  ))
    19  
    20  func cheetahRules() Rules {
    21  	return Rules{
    22  		"root": {
    23  			{`(##[^\n]*)$`, ByGroups(Comment), nil},
    24  			{`#[*](.|\n)*?[*]#`, Comment, nil},
    25  			{`#end[^#\n]*(?:#|$)`, CommentPreproc, nil},
    26  			{`#slurp$`, CommentPreproc, nil},
    27  			{`(#[a-zA-Z]+)([^#\n]*)(#|$)`, ByGroups(CommentPreproc, Using(Python), CommentPreproc), nil},
    28  			{`(\$)([a-zA-Z_][\w.]*\w)`, ByGroups(CommentPreproc, Using(Python)), nil},
    29  			{`(\$\{!?)(.*?)(\})(?s)`, ByGroups(CommentPreproc, Using(Python), CommentPreproc), nil},
    30  			{`(?sx)
    31                  (.+?)               # anything, followed by:
    32                  (?:
    33                   (?=\#[#a-zA-Z]*) | # an eval comment
    34                   (?=\$[a-zA-Z_{]) | # a substitution
    35                   \Z                 # end of string
    36                  )
    37              `, Other, nil},
    38  			{`\s+`, Text, nil},
    39  		},
    40  	}
    41  }
    42  

View as plain text