Code archives/File Utilities/Code2HTML

This code has been declared by its author to be Public Domain code.

Download source code

Code2HTML by XtremeCoder
(Posted 20 years ago)
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

XtremeCoder
(Posted 20 years ago)
ps: any help with the irregular formatting would be appreciated... thanks

Chalky
(Posted 20 years ago)
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...

Perturbatio
(Posted 20 years ago)
I would suggest wrapping the code in <pre></pre> tags instead that way any HTML contained within the source code is not interpreted.

XtremeCoder
(Posted 20 years ago)
oo thanks Perturbatio

Code Archives Forum