Skip to content

Commit 187e7cf

Browse files
committed
remove unsupported negative lookbehind regex
- cherry pick from unreleased branch
1 parent 97f9e88 commit 187e7cf

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

src/languages/r.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,40 @@ export default function(hljs) {
126126
{begin: "'", end: "'", relevance: 0}
127127
],
128128
},
129-
130129
{
131130
className: 'number',
132131
variants: [
133-
// Special case: only hexadecimal binary powers can contain fractions.
134-
{ begin: /(?<![a-zA-Z0-9._])0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/ },
135-
{ begin: /(?<![a-zA-Z0-9._])0[xX][0-9a-fA-F]+([pP][+-]?\d+)?[Li]?/ },
136-
{ begin: /(?<![a-zA-Z0-9._])(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[Li]?/ }
132+
// TODO: replace with negative look-behind when available
133+
// { begin: /(?<![a-zA-Z0-9._])0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/ },
134+
// { begin: /(?<![a-zA-Z0-9._])0[xX][0-9a-fA-F]+([pP][+-]?\d+)?[Li]?/ },
135+
// { begin: /(?<![a-zA-Z0-9._])(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[Li]?/ }
136+
137+
// The below rules all eat an extra character in front (for the
138+
// look-behind check) and then exclude it from the match, but I think
139+
// in many cases this will work out just fine.
140+
{
141+
// Special case: only hexadecimal binary powers can contain fractions.
142+
begin: /([^a-zA-Z0-9._])(?=0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?)/,
143+
end: /0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,
144+
excludeBegin: true
145+
},
146+
{
147+
begin: /([^a-zA-Z0-9._])(?=0[xX][0-9a-fA-F]+([pP][+-]?\d+)?[Li]?)/,
148+
end: /0[xX][0-9a-fA-F]+([pP][+-]?\d+)?[Li]?/ ,
149+
excludeBegin: true
150+
},
151+
{
152+
begin: /([^a-zA-Z0-9._])(?=(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[Li]?)/,
153+
end: /(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[Li]?/,
154+
excludeBegin: true
155+
}
137156
],
157+
// "on:begin": (match, response) => {
158+
// if (match.index > 0) {
159+
// let priorChar = match.input[match.index - 1];
160+
// if (priorChar.match(/[a-zA-Z0-9._]/)) response.ignoreMatch();
161+
// }
162+
// },
138163
relevance: 0
139164
},
140165

0 commit comments

Comments
 (0)