2019-10-27 17:04:31 +01:00
|
|
|
package d
|
|
|
|
|
|
|
|
import (
|
|
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
|
|
"github.com/alecthomas/chroma/lexers/b"
|
|
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
|
|
"github.com/alecthomas/chroma/lexers/j"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Docker lexer.
|
2021-04-28 18:35:32 +02:00
|
|
|
var Docker = internal.Register(MustNewLazyLexer(
|
2019-10-27 17:04:31 +01:00
|
|
|
&Config{
|
|
|
|
Name: "Docker",
|
|
|
|
Aliases: []string{"docker", "dockerfile"},
|
|
|
|
Filenames: []string{"Dockerfile", "*.docker"},
|
|
|
|
MimeTypes: []string{"text/x-dockerfile-config"},
|
|
|
|
CaseInsensitive: true,
|
|
|
|
},
|
2021-04-28 18:35:32 +02:00
|
|
|
dockerRules,
|
|
|
|
))
|
|
|
|
|
|
|
|
func dockerRules() Rules {
|
|
|
|
return Rules{
|
2019-10-27 17:04:31 +01:00
|
|
|
"root": {
|
|
|
|
{`#.*`, Comment, nil},
|
|
|
|
{`(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},
|
2019-11-08 02:24:08 +01:00
|
|
|
{`(LABEL|ENV|ARG)((?:(?:\s*\\?\s*)\w+=\w+(?:\s*\\?\s*))*)`, ByGroups(Keyword, Using(b.Bash)), nil},
|
2019-10-27 17:04:31 +01:00
|
|
|
{`((?: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},
|
|
|
|
},
|
2021-04-28 18:35:32 +02:00
|
|
|
}
|
|
|
|
}
|