markdown: Handle multiple python regex capture groups properly.

Since on replacing the first 'P<>' group, we remove this text from
the string, we have to make the RegExp start looking from index 0
again to properly convert later 'P<>' groups to JS regex syntax.
This commit is contained in:
Natsu Kagami
2019-02-11 16:54:18 -05:00
committed by Tim Abbott
parent 868a763cec
commit d936fcab3b
2 changed files with 7 additions and 0 deletions

View File

@@ -519,6 +519,11 @@ run_test('python_to_js_filter', () => {
var actual_value = marked.InlineLexer.rules.zulip.realm_filters;
var expected_value = [/\/aa\/g(?![\w])/gim, /\/aa\/g(?![\w])/g];
assert.deepEqual(actual_value, expected_value);
// Test case with multiple replacements.
markdown.set_realm_filters([['#cf(?P<contest>[0-9]+)(?P<problem>[A-Z][0-9A-Z]*)', 'http://google.com']]);
actual_value = marked.InlineLexer.rules.zulip.realm_filters;
expected_value = [/#cf([0-9]+)([A-Z][0-9A-Z]*)(?![\w])/g];
assert.deepEqual(actual_value, expected_value);
});
run_test('katex_throws_unexpected_exceptions', () => {