|
39 | 39 | Prism.languages.insertBefore('ruby', 'keyword', {
|
40 | 40 | 'regex': [
|
41 | 41 | {
|
42 |
| - pattern: /%r([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[gim]{0,3}/, |
43 |
| - greedy: true, |
44 |
| - inside: { |
45 |
| - 'interpolation': interpolation |
46 |
| - } |
47 |
| - }, |
48 |
| - { |
49 |
| - pattern: /%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/, |
50 |
| - greedy: true, |
51 |
| - inside: { |
52 |
| - 'interpolation': interpolation |
53 |
| - } |
54 |
| - }, |
55 |
| - { |
56 |
| - // Here we need to specifically allow interpolation |
57 |
| - pattern: /%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/, |
58 |
| - greedy: true, |
59 |
| - inside: { |
60 |
| - 'interpolation': interpolation |
61 |
| - } |
62 |
| - }, |
63 |
| - { |
64 |
| - pattern: /%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/, |
65 |
| - greedy: true, |
66 |
| - inside: { |
67 |
| - 'interpolation': interpolation |
68 |
| - } |
69 |
| - }, |
70 |
| - { |
71 |
| - pattern: /%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/, |
| 42 | + pattern: RegExp(/%r/.source + '(?:' + [ |
| 43 | + /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[gim]{0,3}/.source, |
| 44 | + /\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/.source, |
| 45 | + // Here we need to specifically allow interpolation |
| 46 | + /\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/.source, |
| 47 | + /\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/.source, |
| 48 | + /<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/.source |
| 49 | + ].join('|') + ')'), |
72 | 50 | greedy: true,
|
73 | 51 | inside: {
|
74 | 52 | 'interpolation': interpolation
|
|
102 | 80 |
|
103 | 81 | Prism.languages.ruby.string = [
|
104 | 82 | {
|
105 |
| - pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/, |
106 |
| - greedy: true, |
107 |
| - inside: { |
108 |
| - 'interpolation': interpolation |
109 |
| - } |
110 |
| - }, |
111 |
| - { |
112 |
| - pattern: /%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/, |
113 |
| - greedy: true, |
114 |
| - inside: { |
115 |
| - 'interpolation': interpolation |
116 |
| - } |
117 |
| - }, |
118 |
| - { |
119 |
| - // Here we need to specifically allow interpolation |
120 |
| - pattern: /%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/, |
121 |
| - greedy: true, |
122 |
| - inside: { |
123 |
| - 'interpolation': interpolation |
124 |
| - } |
125 |
| - }, |
126 |
| - { |
127 |
| - pattern: /%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/, |
128 |
| - greedy: true, |
129 |
| - inside: { |
130 |
| - 'interpolation': interpolation |
131 |
| - } |
132 |
| - }, |
133 |
| - { |
134 |
| - pattern: /%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/, |
| 83 | + pattern: RegExp(/%[qQiIwWxs]?/.source + '(?:' + [ |
| 84 | + /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source, |
| 85 | + /\((?:[^()\\]|\\[\s\S])*\)/.source, |
| 86 | + // Here we need to specifically allow interpolation |
| 87 | + /\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/.source, |
| 88 | + /\[(?:[^\[\]\\]|\\[\s\S])*\]/.source, |
| 89 | + /<(?:[^<>\\]|\\[\s\S])*>/.source |
| 90 | + ].join('|') + ')'), |
135 | 91 | greedy: true,
|
136 | 92 | inside: {
|
137 | 93 | 'interpolation': interpolation
|
|
0 commit comments