<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <!--*************************************************************************** ** ** ** Copyright(C) 2005-2006 by L. N. Reed ** ** ** ** Released under the GNU General Public License ** ** www.gnu.org/copyleft/gpl.html ** ** ** ****************************************************************************--> <HTML> <CENTER> <TITLE>Text to HTML</TITLE> <head> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function backButton() { text = "<center>"; text += "<br>"; text += "<input type=button value='Back' "; text += "onClick='window.history.go( -1 )'>"; text += "</center></body></html>"; return( text ); } function showText( textToShow ) { text = "<html><head><title>Text to HTML</title></head>"; text += "<body bgcolor='lightyellow' text='black' >"; text += "<CENTER>"; text += "<H3>Text to HTML</H3><DL>"; text += "<br>"; text += "<form NAME='copy'>"; text += "<textarea NAME='txt' ROWS=20 COLS=80 WRAP=VIRTUAL>"; text += textToShow; text += "</textarea>"; text += "<DIV align='center'>"; text += "<br>"; text += "<input type=button value='Highlight All' "; text += "onClick='javascript:this.form.txt.focus();"; text += "this.form.txt.select();'>"; text += "</DIV>"; text += "</form>"; text += backButton(); window.document.write( text ); window.document.close(); } function putSpaces( nSpaces ) { text = ""; for ( var i = 0; i < nSpaces; i++ ) text += " "; return( text ); } function lineNumber( lineNum, lineFlag ) { text = ""; if ( lineFlag ) { var str = '' + lineNum; text += putSpaces( 4 - str.length ); text += lineNum + ") "; } return( text ); } function convertText( textToConvert, lineFlag, tabWidth ) { var chIndex = -1; var nSpaces = 0; var lineNum = 0; var sLength = textToConvert.length if ( tabWidth == "" ) // drop down menu default tabWidth = 8; text = "\n" + lineNumber( ++lineNum, lineFlag ); for ( var i = 0; i < sLength; i++ ) { chIndex++; switch ( textToConvert.charAt(i) ) { case '<': text += "&lt;"; break; case '>': text += "&gt;"; break; case '&': text += "&amp;"; break; case '\t': // Convert TAB to spaces nSpaces = tabWidth - ( chIndex % tabWidth ); chIndex += nSpaces - 1; text += putSpaces( nSpaces ); break; case '\n': // New Line - maybe print line number text += "\n"; text += lineNumber( ++lineNum, lineFlag ); chIndex = -1; break; default: text += textToConvert.substr(i,1); } } return( text ); } function convertToHTML( textToDisplay, lineNumbers, tabWidth ) { text = "<html><pre><code><br>"; text += convertText( textToDisplay, lineNumbers, tabWidth ); text += "<br></code></pre></html>"; text = convertText( text, 0, tabWidth ); showText( text ); } function previewText( textToShow, lineNumbers, tabWidth ) { text = "<html><head><title>Text to HTML</title></head>"; text += "<body bgcolor='lightyellow' text='black' >"; text += "<html><pre><code><br>"; text += convertText( textToShow, lineNumbers, tabWidth ); text += "<br></code></pre></html>"; text += backButton(); window.document.write( text ); window.document.close(); } function getTabWidth() { document.writeln( "Tab Width <SELECT name='tabWidth'><OPTION value=\"\">8" ); for ( var i = 1; i <= 12; i++ ) document.write( "<OPTION value=\"" + i +"\">" + i + "" ); document.write( "</SELECT>" ); } // End --> </script> </head> <BODY bgColor=lightyellow link=red VLINK=black text=black > <BASEFONT SIZE="2" FACE="Arial"> <H3>Text to HTML</H3><DL> Converts ASCII text into HTML while preserving all formatting. <BR> Paste or type text into window and click on <b>[Preview]</b> or <b>[Convert]</b> <BR><BR> <FORM> <textarea name="data" rows=20 cols=80></textarea> <br> Display Line Numbers <input type="checkbox" name="C1" value="ON"> &nbsp;&nbsp;&nbsp; <SCRIPT LANGUAGE="JavaScript"> <!-- Begin getTabWidth(); // End --> </script> <br><br> <INPUT TYPE="BUTTON" VALUE="Preview Text" onClick="previewText( this.form.data.value, this.form.C1.checked, this.form.tabWidth.value )"> &nbsp;&nbsp;&nbsp; <INPUT TYPE="BUTTON" VALUE="Convert to HTML" onClick="convertToHTML( this.form.data.value, this.form.C1.checked, this.form.tabWidth.value )"> &nbsp;&nbsp;&nbsp; <INPUT TYPE="reset" VALUE="Clear Form"> </FORM> </FONT> </CENTER> </BODY> </HTML>