Closed Jordinateur closed 1 month ago
Hey thanks for this, could you please provide some usage examples for it that (currently) no longer work in v5?
Sure, in my mails, i wrap with <sup>
text with this pattern (x).
I use the Maizzle API, just like this :
const html = await replaceStrings('<p>(1)</p>', {'(\\(\\d\\))': '<sup>$1</sup>'})
In V4, html was
<p><sup>(1)</sup></p>
And in V5 html is
<p><sup>$1</sup></p>
I also use this concept in order to add \ to wrap words inside french quotes like this : « Hi », and some other things on the same principle.
Cool, can you please also add a test for this case in test/transformers.test.js
? Make sure to pull first, had to fix some linting errors.
It's this test:
I'll take care of the types and docs 👍
Sweet, thanks!
Done!
And sorry for the linting, i didn't checked.
Hi
This adjustement aims to let the replacement string make use of the capturing group in the regex.
In the version 4, replace strings transformers allows us to replace (1) by (1). Which is not the case in the version 5, i see it as a regression because i personnally used it in that way but maybe it was intended.
In my PR choosed to detect if the replacement string contains a capturing group reference in order to not have the overload of regex replacement if it's not wanted.
Thank for your time and this project !