Page 1 of 1

Html 2 PBsource

Posted: Mon Mar 25, 2024 4:48 pm
by Caronte3D
About code editor...
It would be interesting to be able to...
  • Paste html code
  • Be able to convert it to a text string with this format and indentation:

Code: Select all

  Html$ =  ~"<button id=\"displayInfo\">Display Info</button>\n"+
           ~"<script>\n"+
           ~"  const displayInfoElement=document.getElementById(\"displayInfo\");\n"+
           ~"  document.addEventListener(\"DOMContentLoaded\", () => {\n"+
           ~"    displayInfoElement.addEventListener(\"click\", () => {\n"+
           ~"      window.displayInfo(1000, 2000).then(result => {\n"+
           ~"      });\n"+
           ~"    });\n"+
           ~"  });\n"+
           ~"</script>";

Re: Html 2 PBsource

Posted: Mon Mar 25, 2024 7:28 pm
by mk-soft
Maybe write a PB tool.
But I would store it as external files. So you can use an HTML editor.

Only as tip

Code: Select all


Macro GetHtml(_label:)
  PeekS(_label_, -1, #PB_UTF8)
EndMacro

DataSection
  htmlscript1:
  IncludeBinary "script1.html"
  Data.w #Null
  htmlscript2:
  IncludeBinary "script2.html"
  Data.w #Null
EndDataSection

Re: Html 2 PBsource

Posted: Mon Mar 25, 2024 8:57 pm
by Caronte3D
Thanks mk-soft :wink:
The IncludeBinary is Ok in most cases, but sometimes I want to change parts of that Html with PB variables.

You are right, may be a PBTool is the best solution.

Re: Html 2 PBsource

Posted: Mon Mar 25, 2024 10:09 pm
by idle
Caronte3D wrote: Mon Mar 25, 2024 8:57 pm Thanks mk-soft :wink:
The IncludeBinary is Ok in most cases, but sometimes I want to change parts of that Html with PB variables.

You are right, may be a PBTool is the best solution.
I wrote a crude tag preprocessor scans the page for <?PB functionname()/> so you can modify an html page saved as pbh using runtime functions. <?PB FillRaceResults()/> I'm intending to add it as an optional plug in to the atomic web server.
but I will have to modify the code to be c compatible. I see no reason I can't modify it to include variables either but you can get them via the get or post call backs set the required variables and the preprocessor generates the snippet as it reads the page.

Re: Html 2 PBsource

Posted: Tue Mar 26, 2024 12:34 am
by Caronte3D
Sounds good, in fact, I will use the Atomic Server after your incredible work enhancing it :D
Thanks :wink: