chroma-markdown/vendor/github.com/alecthomas/chroma/lexers/d/diff.go

34 lines
724 B
Go
Raw Normal View History

package d
2017-10-22 05:37:38 +02:00
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
2017-10-22 05:37:38 +02:00
)
// Diff lexer.
var Diff = internal.Register(MustNewLazyLexer(
2017-10-22 05:37:38 +02:00
&Config{
Name: "Diff",
Aliases: []string{"diff", "udiff"},
2018-01-06 23:02:24 +01:00
EnsureNL: true,
2017-10-22 05:37:38 +02:00
Filenames: []string{"*.diff", "*.patch"},
MimeTypes: []string{"text/x-diff", "text/x-patch"},
},
diffRules,
))
func diffRules() Rules {
return Rules{
2017-10-22 05:37:38 +02:00
"root": {
{` .*\n`, Text, nil},
{`\+.*\n`, GenericInserted, nil},
{`-.*\n`, GenericDeleted, nil},
{`!.*\n`, GenericStrong, nil},
{`@.*\n`, GenericSubheading, nil},
{`([Ii]ndex|diff).*\n`, GenericHeading, nil},
{`=.*\n`, GenericHeading, nil},
{`.*\n`, Text, nil},
},
}
}