Skip to content

Commit 0c139d1

Browse files
committed
Puppet: Make heredoc, comments, regexps and strings greedy. Update known failures and tests.
1 parent d7b2b43 commit 0c139d1

File tree

6 files changed

+25
-18
lines changed

6 files changed

+25
-18
lines changed

components/prism-puppet.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
{
1717
pattern: /(@\(([^"\r\n\/):]+)(?:\/[nrts$uL]*)?\).*(?:\r?\n|\r))(?:.*(?:\r?\n|\r))*?[ \t]*\|?[ \t]*-?[ \t]*\2/,
1818
lookbehind: true,
19+
greedy: true,
1920
alias: 'string',
2021
inside: {
2122
// Matches the end tag
@@ -37,12 +38,14 @@
3738
'multiline-comment': {
3839
pattern: /(^|[^\\])\/\*[\s\S]*?\*\//,
3940
lookbehind: true,
41+
greedy: true,
4042
alias: 'comment'
4143
},
4244
'regex': {
4345
// Must be prefixed with the keyword "node" or a non-word char
4446
pattern: /((?:\bnode\s+|[~=\(\[\{,]\s*|[=+]>\s*|^\s*))\/(?:[^\/\\]|\\[\s\S])+\/(?:[imx]+\b|\B)/,
4547
lookbehind: true,
48+
greedy: true,
4649
inside: {
4750
// Extended regexes must have the x flag. They can contain single-line comments.
4851
'extended-regex': {
@@ -55,11 +58,13 @@
5558
},
5659
'comment': {
5760
pattern: /(^|[^\\])#.*/,
58-
lookbehind: true
61+
lookbehind: true,
62+
greedy: true,
5963
},
6064
'string': {
6165
// Allow for one nested level of double quotes inside interpolation
6266
pattern: /(["'])(?:\$\{(?:[^'"}]|(["'])(?:(?!\2)[^\\]|\\[\s\S])*\2)+\}|(?!\1)[^\\]|\\[\s\S])*\1/,
67+
greedy: true,
6368
inside: {
6469
'double-quoted': {
6570
pattern: /^"[\s\S]*"$/,

components/prism-puppet.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-puppet.html

-13
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,6 @@ <h2>Known failures</h2>
145145
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
146146
</p>
147147

148-
<h3>Comments, regular expressions or substrings that look like heredoc strings</h3>
149-
<pre><code>/* @(foo) */
150-
# @(foo)
151-
" @(foo) "
152-
$foo = /@(foo)/</code></pre>
153-
154-
<h3>Single-line comments or substrings that look like multi-line comments</h3>
155-
<pre><code># foo /* bar */ baz
156-
"foo /* bar */ baz"</code></pre>
157-
158-
<h3>Substrings that look like single-line comment</h3>
159-
<pre><code>"foo #bar baz"</code></pre>
160-
161148
<h3>More than one level of nested braces inside interpolation</h3>
162149
<pre><code>"Foobar ${foo({
163150
bar => {baz => 42}

tests/languages/puppet/comment_feature.test

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
# Foobar
33
/* Foo
44
bar */
5+
/* @(foo) */
6+
# @(foo)
7+
# foo /* bar */ baz
58

69
----------------------------------------------------
710

811
[
912
["comment", "#"],
1013
["comment", "# Foobar"],
11-
["multiline-comment", "/* Foo\r\nbar */"]
14+
["multiline-comment", "/* Foo\r\nbar */"],
15+
["multiline-comment", "/* @(foo) */"],
16+
["comment", "# @(foo)"],
17+
["comment", "# foo /* bar */ baz"]
1218
]
1319

1420
----------------------------------------------------

tests/languages/puppet/regex_feature.test

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ bar # baz
55
$foo = /foo
66
bar # baz
77
/ixm
8+
$foo = /@(foo)/
89

910
----------------------------------------------------
1011

@@ -20,7 +21,9 @@ bar # baz
2021
["comment", "# baz"],
2122
"\r\n/ixm"
2223
]]
23-
]]
24+
]],
25+
["variable", ["$foo"]], ["operator", "="],
26+
["regex", ["/@(foo)/"]]
2427
]
2528

2629
----------------------------------------------------

tests/languages/puppet/string_feature.test

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ baz'
88
"foo
99
$bar
1010
baz"
11+
" @(foo) "
12+
"foo /* bar */ baz"
13+
"foo #bar baz"
1114

1215
----------------------------------------------------
1316

@@ -21,7 +24,10 @@ baz"
2124
"\"foo\r\n",
2225
["interpolation", ["$bar"]],
2326
"\r\nbaz\""
24-
]]]]
27+
]]]],
28+
["string", [["double-quoted", ["\" @(foo) \""]]]],
29+
["string", [["double-quoted", ["\"foo /* bar */ baz\""]]]],
30+
["string", [["double-quoted", ["\"foo #bar baz\""]]]]
2531
]
2632

2733
----------------------------------------------------

0 commit comments

Comments
 (0)