Deprecated usage of RegExp.$1 etc. leads to problems with rhino engine (perhaps newer versions)
Author: foto-andreasCreated Jan 8, 2026Updated Jan 8, 2026
Hi,
after updating a lot of libraries in our project suddenly the following error encounters in showdownjs:
the code
List 1:
- e 11
- e 12
List2:
- e 21
- e 22gives the following html code:
List 1:
<ul>
<li>e 11</li>
<li>e 12</li>
</ul>
List 2:
<ul>
<li>e 11</li>
<li>e 12</li>
</ul>I tracked this town to the shadowjs code where ¨K1K and ¨K2K are replaced. The number is extracted with RegExp.$2, which is deprecated and seems to be broken (in rhino?). It delivers always "1" in the loop.
I think same problem has the ¨CnC unhashing.
The following code solves the problem for us:
// if this is a marker for a html block...
var re = /¨(K|G)(\d+)\1/;
var arr = null;
while ((arr = re.exec(grafsOutIt)) != null) {
var delim = arr[1],
num = arr[2];and in the C-Case:
var re = /¨C(\d+)C/;
var arr = null
while ((arr = re.exec(repText)) != null) {
var num = arr[1];Andreas
Source: showdownjs/showdown