Html 2 PBsource

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Caronte3D
Addict
Addict
Posts: 1029
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Html 2 PBsource

Post 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>";
User avatar
mk-soft
Always Here
Always Here
Posts: 5337
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Html 2 PBsource

Post 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
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Caronte3D
Addict
Addict
Posts: 1029
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Html 2 PBsource

Post 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.
User avatar
idle
Always Here
Always Here
Posts: 5050
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Html 2 PBsource

Post 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.
User avatar
Caronte3D
Addict
Addict
Posts: 1029
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Html 2 PBsource

Post by Caronte3D »

Sounds good, in fact, I will use the Atomic Server after your incredible work enhancing it :D
Thanks :wink:
Post Reply