Skip to content

Commit

Permalink
Fix notation of named stages in multi-stage docker builds (#1809)
Browse files Browse the repository at this point in the history
* Fix notation of named stages in multi-stage docker builds

* Check for whitespace as well to mitigate "AS" appearing in image names

* Add multi-stage builder pattern to sample
  • Loading branch information
bartbroere committed Mar 8, 2022
1 parent e22c85a commit 8310e1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rouge/lexers/docker.rb
Expand Up @@ -20,6 +20,10 @@ class Docker < RegexLexer
state :root do
rule %r/\s+/, Text

rule %r/^(FROM)(\s+)(.*)(\s+)(AS)(\s+)(.*)/io do
groups Keyword, Text::Whitespace, Str, Text::Whitespace, Keyword, Text::Whitespace, Str
end

rule %r/^(ONBUILD)(\s+)(#{KEYWORDS})(.*)/io do
groups Keyword, Text::Whitespace, Keyword, Str
end
Expand Down
1 change: 1 addition & 0 deletions spec/visual/samples/docker
@@ -1,3 +1,4 @@
FROM golang:1.16 AS builder
maintainer First O'Last

run echo \
Expand Down

0 comments on commit 8310e1c

Please sign in to comment.