Code archives/File Utilities/Code2HTML
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Turns code into an HTML file, good for open source distributions... Sometimes/rarely the code will come out formatted and centered for whatever reason... depending on your code that may or may not happen... | |||||
Function Code2HTML(file$,author$) codefile=OpenFile(file$) htmlfile=WriteFile(file$+".html") WriteLine(htmlfile, "<html>") WriteLine(htmlfile, "<head><title>"+ file$ + "</title></head>") WriteLine(htmlfile, "<body bgcolor=000000 Text=66CCFF >") WriteLine(htmlfile, "<center>") WriteLine(htmlfile, "<h1>"+ file$ + "</h1>") WriteLine(htmlfile, "<p><h3>Date: "+ CurrentDate() + "</h3>") WriteLine(htmlfile, "<h3>Author: "+ author$ +"</h3>") WriteLine(htmlfile, "</center>") WriteLine(htmlfile, "<hr>") WriteLine(htmlfile, "<center>") WriteLine(htmlfile, "<h2>Code:</h2>") WriteLine(htmlfile, "</center>") While Not Eof(codefile) ReadCode$ = ReadLine( codefile ) WriteLine(htmlfile, "<p>"+ReadCode$) Wend WriteLine(htmlfile, "</body>") WriteLine(htmlfile, "</html>") CloseFile(htmlfile) CloseFile(codefile) End Function |
Comments
| ||
ps: any help with the irregular formatting would be appreciated... thanks |
| ||
Strictly speaking you should terminate your paragraph tags:WriteLine(htmlfile, "<p>"+ReadCode$+"</p>") as some browsers get confused if you don't. No idea if this cures it but probably worth doing anyway for neatness... |
| ||
I would suggest wrapping the code in <pre></pre> tags instead that way any HTML contained within the source code is not interpreted. |
| ||
oo thanks Perturbatio |
Code Archives Forum