[x3d-public] Foray into ES6 SAI HelloWorld.mjs. Look at x3d.py examples? Best way to do comments in ECMAScript?

John Carlson yottzumm at gmail.com
Sat Apr 17 20:09:26 PDT 2021


For those of you who want to keep up with me (I don't really know how to 
use git branches), the following possibly temporary patch is made to 
X3DJSONLD.  Help formatting the XML output would be highly desired 
(found in the es6x3d repository).  Executable programs are found in: 
~/X3DJSONLD/src/main/node/net/ecma/data I'm just starting to run them.  
There are many errors.  Even some in ECMAScriptSerializer.js (SourceCode 
for Scripts comes to mind). But right now, I'm just trying to get 
HelloWorld.mjs to work. Here's how I run it: `node HelloWorld.mjs`.  
Someone could run the output (XML piece) from that command through the 
X3D validator. Someone could render the XML output.   Well, I'm going to 
run for food!

diff --git a/src/main/node/ECMAScriptSerializer.js 
b/src/main/node/ECMAScriptSerializer.js
index d4d71e210..5a1913e1b 100644
--- a/src/main/node/ECMAScriptSerializer.js
+++ b/src/main/node/ECMAScriptSerializer.js
@@ -360,8 +360,8 @@ ECMAScriptSerializer.prototype = {
                                 var y = node.nodeValue.
                                         replace(/\\/g, '\\\\').
                                         replace(/"/g, '\\"');
-                               childs.push("\n"+(" ".repeat(n))+'{ 
"#comment" : new CommentsBlock("'+y.split("\n").join('\\n\"+\n\"')+'") }');
-                               this.precode["CommentsBlock"] = true;
+                               childs.push("\n"+(" 
".repeat(n))+'/*'+y.split("\n").join('\\n\"+\n\"')+'*/');^M
+                               // this.precode["CommentsBlock"] = true;^M
                                 if (y !== node.nodeValue) {
                                         // console.error("ECMAScript 
Comment Replacing "+node.nodeValue+" with "+y);
                                 }
@@ -381,6 +381,11 @@ ECMAScriptSerializer.prototype = {
                 if (closeMFNode) {
                         ch += "])";
                 }
+               let cmt = ch.indexOf("*/,");
+               while (cmt > 0) {
+                       ch = ch.substring(0, cmt)+"*/"+ch.substring(cmt+3);
+                       cmt = ch.indexOf("*/,");
+               }
                 return ch;

         }





More information about the x3d-public mailing list