Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Add dockerfile highlighter
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Jul 8, 2021
1 parent 68d0021 commit bcba7fe
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions syntax/docker.krk
@@ -0,0 +1,37 @@
from syntax import Highlighter, bind
from syntax.bash import BashHighlighter

@bind
class DockerfileHighlighter(BashHighlighter):
name = "docker"
extensions = ('Dockerfile',)
spaces = True

keywords = [
'FROM','AS','MAINTAINER','RUN','CMD','COPY','EXPOSE','ADD',
'ENTRYPOINT','VOLUME','USER','WORKDIR','ONBUILD','LABEL','ARG',
'HEALTHCHECK','SHELL','STOPSIGNAL',
]

def calculate(self):
if self.state < 1 and self.i == 0:
if self[0] == '#':
self.paintComment()
else if self.matchAndPaint('RUN', self.FLAG_KEYWORD, self.cKeywordQualifier):
let out = super().calculate()
if out == None and self[-1] == '\\':
return 1
return out
else if self.findKeywords(self.keywords, self.FLAG_KEYWORD, self.cKeywordQualifier):
return 0
else:
self.skip(1)
else:
if self.state == 1:
self.set_state(0)
let out = super().calculate()
if out == None and self[-1] == '\\':
return 1
return out
return None

0 comments on commit bcba7fe

Please sign in to comment.