Sha256: 5d23be32a637f4d27127180674eae244326cab13114046cfe629ab54ec909a9d
Contents?: true
Size: 593 Bytes
Versions: 6
Compression:
Stored size: 593 Bytes
Contents
function regexText(node) { if (node.nodeType == 3) { // is it a text node? const reg = /\*\*(\S+)\*\*/g; const replacement = '<span class="typography__power-text">$1</span>'; const nodeContainsMatch = node.data.search(reg) != -1; if (nodeContainsMatch) { node.parentElement.innerHTML = node.parentElement.innerHTML.replace(reg, replacement); } } if (node.nodeType == 1 && node.nodeName != 'SCRIPT') { for (var i = 0; i < node.childNodes.length; i++) { regexText(node.childNodes[i]); } } } // regexText(document.body); export default regexText;
Version data entries
6 entries across 6 versions & 1 rubygems