...

Source file src/github.com/alecthomas/chroma/lexers/d/diff.go

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

     1  package d
     2  
     3  import (
     4  	. "github.com/alecthomas/chroma" // nolint
     5  	"github.com/alecthomas/chroma/lexers/internal"
     6  )
     7  
     8  // Diff lexer.
     9  var Diff = internal.Register(MustNewLazyLexer(
    10  	&Config{
    11  		Name:      "Diff",
    12  		Aliases:   []string{"diff", "udiff"},
    13  		EnsureNL:  true,
    14  		Filenames: []string{"*.diff", "*.patch"},
    15  		MimeTypes: []string{"text/x-diff", "text/x-patch"},
    16  	},
    17  	diffRules,
    18  ))
    19  
    20  func diffRules() Rules {
    21  	return Rules{
    22  		"root": {
    23  			{` .*\n`, Text, nil},
    24  			{`\+.*\n`, GenericInserted, nil},
    25  			{`-.*\n`, GenericDeleted, nil},
    26  			{`!.*\n`, GenericStrong, nil},
    27  			{`@.*\n`, GenericSubheading, nil},
    28  			{`([Ii]ndex|diff).*\n`, GenericHeading, nil},
    29  			{`=.*\n`, GenericHeading, nil},
    30  			{`.*\n`, Text, nil},
    31  		},
    32  	}
    33  }
    34  

View as plain text