Here is another option, in TypeScript:
const addWordBreakAfterUnderscores = (content: string) => {
// u200B is a zero-width space, which is used to prevent
// the wordbreak from being visible.
return content.replaceAll('_', '_\u200B');
};