2018-05-01 02:37:51 +05:00
|
|
|
package d
|
|
|
|
|
|
|
|
import (
|
|
|
|
. "github.com/alecthomas/chroma" // nolint
|
2019-10-13 13:55:38 +05:00
|
|
|
"github.com/alecthomas/chroma/lexers/b"
|
2018-05-01 02:37:51 +05:00
|
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
2019-10-13 13:55:38 +05:00
|
|
|
"github.com/alecthomas/chroma/lexers/j"
|
2018-05-01 02:37:51 +05:00
|
|
|
)
|
|
|
|
|
|
|
|
// Docker lexer.
|
|
|
|
var Docker = internal.Register(MustNewLexer(
|
|
|
|
&Config{
|
|
|
|
Name: "Docker",
|
|
|
|
Aliases: []string{"docker", "dockerfile"},
|
|
|
|
Filenames: []string{"Dockerfile", "*.docker"},
|
|
|
|
MimeTypes: []string{"text/x-dockerfile-config"},
|
|
|
|
CaseInsensitive: true,
|
|
|
|
},
|
|
|
|
Rules{
|
|
|
|
"root": {
|
|
|
|
{`#.*`, Comment, nil},
|
2019-10-13 13:55:38 +05:00
|
|
|
{`(ONBUILD)((?:\s*\\?\s*))`, ByGroups(Keyword, Using(b.Bash)), nil},
|
|
|
|
{`(HEALTHCHECK)(((?:\s*\\?\s*)--\w+=\w+(?:\s*\\?\s*))*)`, ByGroups(Keyword, Using(b.Bash)), nil},
|
|
|
|
{`(VOLUME|ENTRYPOINT|CMD|SHELL)((?:\s*\\?\s*))(\[.*?\])`, ByGroups(Keyword, Using(b.Bash), Using(j.JSON)), nil},
|
|
|
|
{`(LABEL|ENV|ARG)(((?:\s*\\?\s*)\w+=\w+(?:\s*\\?\s*))*)`, ByGroups(Keyword, Using(b.Bash)), nil},
|
|
|
|
{`((?:FROM|MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)|VOLUME)\b(.*)`, ByGroups(Keyword, LiteralString), nil},
|
|
|
|
{`((?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY))`, Keyword, nil},
|
|
|
|
{`(.*\\\n)*.+`, Using(b.Bash), nil},
|
2018-05-01 02:37:51 +05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
))
|