From 8310e1c0b17cf777a1c1642ef48b802f306da504 Mon Sep 17 00:00:00 2001
From: Bart Broere <mail@bartbroere.eu>
Date: Tue, 8 Mar 2022 03:17:05 +0100
Subject: [PATCH] Fix notation of named stages in multi-stage docker builds
 (#1809)

* 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
---
 lib/rouge/lexers/docker.rb | 4 ++++
 spec/visual/samples/docker | 1 +
 2 files changed, 5 insertions(+)

diff --git a/lib/rouge/lexers/docker.rb b/lib/rouge/lexers/docker.rb
index 9b026dc196..2b4467bc4f 100644
--- a/lib/rouge/lexers/docker.rb
+++ b/lib/rouge/lexers/docker.rb
@@ -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
diff --git a/spec/visual/samples/docker b/spec/visual/samples/docker
index 656d2bc1d8..34604f22eb 100644
--- a/spec/visual/samples/docker
+++ b/spec/visual/samples/docker
@@ -1,3 +1,4 @@
+FROM golang:1.16 AS builder
 maintainer First O'Last
 
 run echo \