in reply to Formatting a text file for browser

You want text to display in the browser just like it would display in notepad? Wrap your ascii file in <pre> tags, and you'll be set... almost too easy :)

Replies are listed 'Best First'.
Re: Re: Formatting a text file for browser
by tachyon (Chancellor) on Aug 31, 2001 at 16:38 UTC

    Actually no. You will need to escape all the HTML special characters for them to display. Here is an example. The text is "Wrap your ascii file in <pre> tags, and you'll be set... almost too easy :)"

    "Wrap your ascii file in 
     tags, and you'll be set... almost too easy :)"

    Hmmm, not actually the text I wanted. I'll close that unmatched pre now

    CGI.pm has an escapeHTML method to do this $html = $q->escapeHTML($text) As a browser will only render 1 space even if you have 10 in a row or tabs you need to escape these to. I have posted a solution in this thread - see below.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print