1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-01-14 02:23:16 +02:00
chroma/lexers/diff.go
Alec Thomas a10fd0a23d Switch to github.com/dlclark/regexp2.
This makes translating Pygments lexers much much simpler (and possible).
2017-09-18 11:16:44 +10:00

28 lines
603 B
Go

package lexers
import (
. "github.com/alecthomas/chroma" // nolint
)
// Diff lexer.
var Diff = Register(MustNewLexer(
&Config{
Name: "Diff",
Aliases: []string{"diff", "udiff"},
Filenames: []string{"*.diff", "*.patch"},
MimeTypes: []string{"text/x-diff", "text/x-patch"},
},
Rules{
"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},
},
},
))