From aae80a166f05d7ce04b9bb6ec772930c2bba9ec1 Mon Sep 17 00:00:00 2001 From: DeltaLima Date: Tue, 20 Jun 2023 23:47:09 +0200 Subject: [PATCH] the most hard work is done i guess --- plugin.syntaxhighlighter.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/plugin.syntaxhighlighter.php b/plugin.syntaxhighlighter.php index dbcc70b..50ff1fb 100644 --- a/plugin.syntaxhighlighter.php +++ b/plugin.syntaxhighlighter.php @@ -100,30 +100,41 @@ function plugin_syntaxhighlighter_foot() { // wrap the content of
 elements into  for prismjs
             
             // get an array of pre elements 
-            var preEl = document.getElementsByTagName("pre");
+            //var preEl = document.getElementsByTagName("pre");
             
             // split used_languages list into array
             let used_languages = $used_languages;
             
             for (let iUl = 0;iUl < used_languages.length; iUl++)
             {
+              // do nothing on empty elements
               if ( used_languages[iUl] != "" ) 
               {
                 alert(used_languages[iUl]);
+                let preElements = document.querySelectorAll("pre." + used_languages[iUl]);
+                
+                for (let iEl = 0;iEl < preElements.length; iEl++)
+                {
+                  org_html = preElements[iEl].innerHTML;
+                  new_html = "" + org_html + "";
+                  alert(new_html);
+                  preElements[iEl].innerHTML = new_html;
+                }
               }
             }
             
             
             
-            for(let iEl = 0;iEl < preEl.length; iEl++)
+            /* for(let iEl = 0;iEl < preEl.length; iEl++)
             {
               //ShowResults(input[iEl].value);
               //alert(preEl[iEl].innerHTML);
+              
               org_html = preEl[iEl].innerHTML;
               new_html = "" + org_html + "";
               preEl[iEl].innerHTML = new_html;
               
-            }
+            } */