From 7a6cd4a40be60be67aa1cc5534fffa2e348e329a Mon Sep 17 00:00:00 2001
From: weru <onewesh@gmail.com>
Date: Thu, 12 Nov 2020 02:50:24 +0000
Subject: [PATCH] save file

---
 assets/js/functions.js |   38 +++++++++++++++++++++++++++++---------
 1 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/assets/js/functions.js b/assets/js/functions.js
index 4e8a811..9b17076 100644
--- a/assets/js/functions.js
+++ b/assets/js/functions.js
@@ -107,17 +107,37 @@
   }
 }
 
+
 function wrapText(text, context, wrapper = 'div') {
   let c = context.textContent;
   let index = c.indexOf(text);
-  console.log(context);
-  // h1, h2, h3, h4, h5, h6, p, code, a,
-  if (index >= 0) {
-    let stop = index + text.length;
-    let s = c.substring(index,stop);
-    let before = c.substring(0,index);
-    let after = c.substring(stop);
-    c = `${before}<${wrapper}>${s}</${wrapper}>${after}`;
-    context.textContent = c;
+
+  function wrap() {
+    if (index >= 0) {
+      let stop = index + text.length;
+      let s = c.substring(index,stop);
+      let before = c.substring(0,index);
+      let after = c.substring(stop);
+      c = `${before}<${wrapper}>${s}</${wrapper}>${after}`;
+      context.textContent = c;
+    }
   }
+
+  const contents = ["h1", "h2", "h3", "h4", "h5", "h6", "p", "code"];
+  const attributes = ["href", "title", "class", "id"];
+  const children = ["span", "em", "strong", "b", "a"];
+  contents.forEach(function(c){
+    const cs = elems(c);
+    if(cs.length) {
+      cs.forEach(function(cx){
+        // console.log(cx);
+        // check if
+        // if has children
+           // check if childen is in children array above
+           // check if children contain attributes
+          // process before replacing
+        // else replace and move on
+      });
+    }
+  });
 }
\ No newline at end of file

--
Gitblit v1.10.0