7777 66

I'm trying to get several text files to wrap when displayed in Firefox, instead of running off the screen. Is there a way to do that?

Particularly, I would like it to wrap like a Usenet message, like so:

http://groups.google.com/group/alt.pagan.magick/msg/6beb96a17d4d5971?dmode=source&output=gplain

Thanks.

7 answers

2
points
This was chosen as the best answer

http://sandbox.ryanaghdam.com/wrap/

  • test.txt: A plain text file with many paragaphs without line breaks
  • wrap.php: The actual PHP source code. Open this to see the test.txt file wrapped correctly
  • wrap.php.html: HTML-version of the source code (with syntax-highlighting) for your viewing.

If you have any questions, please find my contact information here: http://ryanaghdam.com/contact. I would prefer you'd tell me if you're going to use the code in your website.

Answered almost 5 years ago by Ryan Aghdam
  • Link was broken... what makes this the chosen answer? Adam Monsen almost 4 years ago
  • Argh, I meant to say 'the link is broken' (regarding the link to http://sandbox.ryanaghdam.com/wrap/), but I can't edit my comment. Adam Monsen almost 4 years ago
0
points

Set up a div, specify a width, 800px or so and output that data in that div.

css

#container {width: 800px;}

html

<div id="container">DATA</div>
Answered almost 5 years ago by Ben Shoults
7777 66
0
points

I should specify, these files will be .txt files not .html.

So more like this actually:

http://www.textfiles.com/100/adventur.txt

Answered almost 5 years ago by 7777
0
points

I should specify, these files will be .txt files not .html.

I think that (should have) answered your question.

If you have a server-side scripting language, you could either:

  1. Have it read the text file, and insert a newline character before each word that breaks the 80-columsn mark, and print the result.
  2. Take the text file as input and print it in an HTML document with the body width set to 66ex.
Answered almost 5 years ago by Ryan Aghdam
7777 66
0
points

Yes I think the first option is more what I'm looking for. I'd like the documents to remain plaintext files. Is there a way I can accomplish this with PHP then? Although I should say that I really have very little PHP experience to speak of.

Answered almost 5 years ago by 7777
0
points

Okay, sounds like a bit of a challenge. I'm going to figure this one out and post a link to the results.

Answered almost 5 years ago by Ryan Aghdam
7777 66
0
points

That. Is. Brilliant! Thank you so much, I've been trying to figure this out for days!

I am planning on using this on a personal website that hasn't gone up yet, but when it goes up I will definitely tell you!

Answered almost 5 years ago by 7777
  • Glad it's helpful. Let me know if it will work out for your website the right way. I'll be happy to make changes to make it work better for you. Ryan Aghdam almost 5 years ago