Page 1 of 2

Auto formatting tool for pure text documents?

Posted: Thu Jan 06, 2005 2:56 am
by KimmoA
Is there a feature/plug-in in TextPad which formats pure text documents in such way that it makes a linebreak every nth char? I want some kind of standard look -- not all file-editors have word-wrapping on by default. :(

Also, if there is such a thing, does it also create spaces between words when there's "too little" text on one line to fill it up completely (like two spaces instead of one between some words)? :roll:

Posted: Thu Jan 06, 2005 9:56 am
by MudGuard
Have you tried
Edit - Reformat
and
Edit - Align - Left/Right/Center/Justify
?

Posted: Thu Jan 06, 2005 2:34 pm
by KimmoA
Sorry, but those options basically just **** everything up.

I simply want an automated linebreak for every line that is longer than n chars.

BUT... it'd also be nice to have justify align, too. Those I tried didn't even remotely do what I wanted :(

Posted: Thu Jan 06, 2005 2:43 pm
by A bit iffy

Posted: Thu Jan 06, 2005 4:23 pm
by KimmoA
A bit iffy wrote:Is this what you want?
http://www.textpad.info/forum/viewtopic.php?t=6035
No... it does what I want as long as I have TextPad open, but in my browser, it's still not word-wrapped with \ns.

Posted: Thu Jan 06, 2005 4:53 pm
by ben_josephs
This is a question for your browser, not TextPad.

Which browser are you using?

Does your file contain just plain text, or does it have HTML mark-up?

Have you tried giving the file an extension of .html ?

Posted: Thu Jan 06, 2005 5:00 pm
by MudGuard
Ah, you didn't mention browsers before.

In html - put the text in question into a pre element.

Posted: Thu Jan 06, 2005 5:15 pm
by KimmoA
MudGuard wrote:Ah, you didn't mention browsers before.

In html - put the text in question into a pre element.
WTF? Wasn't my comment added?

Oh, well...

I'm not talking about HTML. This is a pure text document. Web browsers can view those as well.

Posted: Thu Jan 06, 2005 7:34 pm
by MudGuard
what is your setting under

Configure - Preferences - Document Classes - your document class
for
Word wrapped text:
- save with no breaks
or
- save with hard breaks
?

Posted: Thu Jan 06, 2005 10:49 pm
by KimmoA
MudGuard wrote:what is your setting under

Configure - Preferences - Document Classes - your document class
for
Word wrapped text:
- save with no breaks
or
- save with hard breaks
?
At the time: hard breaks.

I did exactly as the instructions said :?

Posted: Fri Jan 07, 2005 2:20 pm
by ben_josephs
If your browser thinks that your file contains HTML it will treat newlines the same as spaces.

In what sense is the text not word-wrapped? Does it extend beyond the right margin of the browser?
Are there sufficient spaces in the text at which the lines can be broken?
Which browser are you using?
What is the file name extension?
How are you opening the file?

Posted: Fri Jan 07, 2005 3:38 pm
by KimmoA
ben_josephs wrote:If your browser thinks that your file contains HTML it will treat newlines the same as spaces.

In what sense is the text not word-wrapped? Does it extend beyond the right margin of the browser?
Are there sufficient spaces in the text at which the lines can be broken?
Which browser are you using?
What is the file name extension?
How are you opening the file?
It doesn't. I serve text files as text files :)

In the Web browser (Opera), it is not word-wrapped in the sense that it looks just like it used to -- looong lines.

Posted: Sat Jan 08, 2005 9:43 am
by Jan Paul
A long line is indeed shown as a long line in a browser.
I have found no "wrap" function in a browser until this time.

Do you use Unix style line breaks? There could be a problem too.

The fact that a browser can show text files is just a 'bonus'. It is not another way of showing textfiles with formatting. If you are very keen on keeping the formatting just right, use another program to format things (PDF/Word etc).

Are you just letting users see textfiles without changing the textfiles themselves? That way you never get formatting to work.
If they only need to see a formatted textfile, put an HTML envelope around the textfile and use replace to change the EOL into <BR>.

You can also do a change after the nth column into <BR>. Use a regular expression to do this. There are examples of this in this forum.

An automated tool could be PHP. Then you can read in the textfile, and after the nth position, put in the <BR>. Make it into a class and you can use it for every textfile. There are examples of this on the PHP website (www.php.net) and many others.

Regards,
Jan Paul

Posted: Sat Jan 08, 2005 12:59 pm
by KimmoA
Jan Paul wrote:A long line is indeed shown as a long line in a browser.
I have found no "wrap" function in a browser until this time.

Do you use Unix style line breaks? There could be a problem too.

The fact that a browser can show text files is just a 'bonus'. It is not another way of showing textfiles with formatting. If you are very keen on keeping the formatting just right, use another program to format things (PDF/Word etc).

Are you just letting users see textfiles without changing the textfiles themselves? That way you never get formatting to work.
If they only need to see a formatted textfile, put an HTML envelope around the textfile and use replace to change the EOL into <BR>.

You can also do a change after the nth column into <BR>. Use a regular expression to do this. There are examples of this in this forum.

An automated tool could be PHP. Then you can read in the textfile, and after the nth position, put in the <BR>. Make it into a class and you can use it for every textfile. There are examples of this on the PHP website (www.php.net) and many others.

Regards,
Jan Paul
I don't have a single problem doing this embedded in HTML. The thing is that I provide the alternative for my users to read the text-file being embedded (user agreement) as pure text, and I'd PREFER if they saw it properly formatted.

:?

Posted: Sat Jan 08, 2005 3:57 pm
by MudGuard
Do you have a Mozilla browser?

If so, please view one of your problematic files with it, then in its context menu, select "View Page Info".

What does it say there under "Type" on the "General" tab?