Skip to content

Commit

Permalink
Add tests for Docker + optimized strings + fixed punctuation
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Sep 5, 2015
1 parent c4fe72b commit e49f7cf
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 4 deletions.
6 changes: 3 additions & 3 deletions components/prism-docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Prism.languages.docker = {
pattern: /(^\s*)(?:ONBUILD|FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|COPY|VOLUME|USER|WORKDIR|CMD|LABEL|ENTRYPOINT)(?=\s)/mi,
lookbehind: true
},
'string': /("|')(\\\n|\\?.)*?\1/,
'string': /("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*?\1/,
'comment': /#.*/,
'punctuation': /([:[\]{}\-,|>?]|---|\.\.\.)/
};
'punctuation': /---|\.\.\.|[:[\]{}\-,|>?]/
};
2 changes: 1 addition & 1 deletion components/prism-docker.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tests/languages/docker/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# foobar

----------------------------------------------------

[
["comment", "#"],
["comment", "# foobar"]
]

----------------------------------------------------

Checks for comments.
37 changes: 37 additions & 0 deletions tests/languages/docker/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
ONBUILD ADD . /app/src
FROM ubuntu
MAINTAINER SvenDowideit@home.org.au
RUN cd /tmp
EXPOSE 5900
ENV myName John Doe
COPY hom* /mydir/
VOLUME /myvol
USER daemon
WORKDIR /a
CMD echo "foo"
LABEL version="1.0"
ENTRYPOINT ["top", "-b"]

----------------------------------------------------

[
["keyword", "ONBUILD"], ["keyword", "ADD"], " . /app/src\r\n",
["keyword", "FROM"], " ubuntu\r\n",
["keyword", "MAINTAINER"], " SvenDowideit@home.org.au\r\n",
["keyword", "RUN"], " cd /tmp\r\n",
["keyword", "EXPOSE"], " 5900\r\n",
["keyword", "ENV"], " myName John Doe\r\n",
["keyword", "COPY"], " hom* /mydir/\r\n",
["keyword", "VOLUME"], " /myvol\r\n",
["keyword", "USER"], " daemon\r\n",
["keyword", "WORKDIR"], " /a\r\n",
["keyword", "CMD"], " echo ", ["string", "\"foo\""],
["keyword", "LABEL"], " version=", ["string", "\"1.0\""],
["keyword", "ENTRYPOINT"],
["punctuation", "["], ["string", "\"top\""], ["punctuation", ","],
["string", "\"-b\""], ["punctuation", "]"]
]

----------------------------------------------------

Checks for keywords.
23 changes: 23 additions & 0 deletions tests/languages/docker/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
""
"fo\"obar"
"foo\
bar"
''
'fo\'obar'
'foo\
bar'

----------------------------------------------------

[
["string", "\"\""],
["string", "\"fo\\\"obar\""],
["string", "\"foo\\\r\nbar\""],
["string", "''"],
["string", "'fo\\'obar'"],
["string", "'foo\\\r\nbar'"]
]

----------------------------------------------------

Checks for strings.

0 comments on commit e49f7cf

Please sign in to comment.