The newSubStr parameter of .replace() can contain replacement patterns
starting with $. The pattern $$ inserts a single $.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter
Bug: T149816
Change-Id: I69619357b7091e302e50398c6258a321346a6240
$( '<span>' ).addClass( 'comment' ).html(
// There is no equivalent to rawParams
mw.message( 'parentheses' ).escaped()
- .replace( '$1', parse.parsedsummary )
+ // .replace() use $ as start of a pattern.
+ // $$ is the pattern for '$'.
+ // The inner .replace() duplicates any $ and
+ // the outer .replace() simplifies the $$.
+ .replace( '$1', parse.parsedsummary.replace( /\$/g, '$$$$' ) )
)
);
}