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
points
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.
- Link was broken... what makes this the chosen answer?
- 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.
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>
points
I should specify, these files will be .txt files not .html.
So more like this actually:
http://www.textfiles.com/100/adventur.txt
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:
- Have it read the text file, and insert a newline character before each word that breaks the 80-columsn mark, and print the result.
- Take the text file as input and print it in an HTML document with the body width set to 66ex.
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.
points
Okay, sounds like a bit of a challenge. I'm going to figure this one out and post a link to the results.
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!
- 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.
