Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 31x 11x 11x 30x 30x 15x 15x | import matchString from '../matchString';
import css from '../../../../styles/stringMatchStyles.css';
const boldString = (match, str, ignoreNull = true, simpleSplit = true) => {
const [parts, regex] = matchString(match, str, ignoreNull, simpleSplit);
return (
parts.map((part, i) => {
// RegExp is stateful, set up a new one to work with
const immutableRegex = new RegExp(regex);
if (immutableRegex.exec(part) !== null) {
return (
<strong
key={`bold-strong-${part}-${i}`}
className={css.whitespacePre}
>
{part}
</strong>
);
}
return (
<span
key={`bold-span-${part}-${i}`}
className={css.whitespacePre}
>
{part}
</span>
);
})
);
};
export default boldString;
|