Dockerfile: Fixed strings inside comments (#2428)
Strings inside comments broke comments. Comments are now greedy, so this can't happen anymore.
This commit is contained in:
parent
ff74a61063
commit
37273a6f79
|
@ -4,7 +4,10 @@ Prism.languages.docker = {
|
|||
lookbehind: true
|
||||
},
|
||||
'string': /("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/,
|
||||
'comment': /#.*/,
|
||||
'comment': {
|
||||
pattern: /#.*/,
|
||||
greedy: true
|
||||
},
|
||||
'punctuation': /---|\.\.\.|[:[\]{}\-,|>?]/
|
||||
};
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Prism.languages.docker={keyword:{pattern:/(^\s*)(?:ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|ONBUILD|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)(?=\s)/im,lookbehind:!0},string:/("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/,comment:/#.*/,punctuation:/---|\.\.\.|[:[\]{}\-,|>?]/},Prism.languages.dockerfile=Prism.languages.docker;
|
||||
Prism.languages.docker={keyword:{pattern:/(^\s*)(?:ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|ONBUILD|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)(?=\s)/im,lookbehind:!0},string:/("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/,comment:{pattern:/#.*/,greedy:!0},punctuation:/---|\.\.\.|[:[\]{}\-,|>?]/},Prism.languages.dockerfile=Prism.languages.docker;
|
|
@ -2,6 +2,8 @@
|
|||
<pre><code># These are the comments for a dockerfile.
|
||||
# I want to make sure $(variables) don't break out,
|
||||
# and we shouldn't see keywords like ADD or ENTRYPOINT
|
||||
|
||||
# I also want to make sure that this "string" and this 'string' don't break out.
|
||||
</code></pre>
|
||||
|
||||
<h2>Full example</h2>
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
#
|
||||
# foobar
|
||||
# "foo" 'bar'
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["comment", "#"],
|
||||
["comment", "# foobar"]
|
||||
["comment", "# foobar"],
|
||||
["comment", "# \"foo\" 'bar'"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue