Sha256: 4b921d688aa7246e2ff297f5d85e30daf9281e5f1857a9adb4a307562c98c020

Contents?: true

Size: 689 Bytes

Versions: 58

Compression:

Stored size: 689 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]);
    }
  }
}
//  USAGE:
//    document.addEventListener('DOMContentLoaded', function() [
//      regexText(document.body);
//    ]);
//
//
export default regexText;

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
kcc-gem-theme-1.20.2 assets/js/theme/src/boldFont.js
kcc-gem-theme-1.19.2 assets/js/theme/src/boldFont.js
kcc-gem-theme-1.18.2 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.17.2 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.16.2 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.15 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.14 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.13 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.12 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.11 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.10 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.9 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.8 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.7 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.6 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.5 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.4 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.3 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.2 assets/js/theme/script/boldFont.js
kcc-gem-theme-1.0.1 assets/js/theme/script/boldFont.js