Auto formatting tool for pure text documents?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

KimmoA
Posts: 17
Joined: Thu Jan 06, 2005 2:51 am
Location: Sweden
Contact:

Post by KimmoA »

MudGuard wrote: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?
"text/plain", of course (I actually checked!)...
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

just wanted to go sure.

Hm. I run out of ideas ...
KimmoA
Posts: 17
Joined: Thu Jan 06, 2005 2:51 am
Location: Sweden
Contact:

Post by KimmoA »

MudGuard wrote:just wanted to go sure.

Hm. I run out of ideas ...
:(
User avatar
Jan Paul
Posts: 21
Joined: Mon Apr 28, 2003 1:24 pm
Location: The Netherlands

Post by Jan Paul »

KimmoA wrote: 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.
:?
Textfiles are always show "as-is" into any browser without ANY formatting. Case closed :?

I you need a text-based user agreement, make an HTML version and a PDF version. Everyone could see the HTML version and can keep a PDF version for downloading (if they need this).
I do not see any reason to not make the user agreement into an HTML file over a text file. Every OS can handle HTML files.

Regards,
Jan Paul
KimmoA
Posts: 17
Joined: Thu Jan 06, 2005 2:51 am
Location: Sweden
Contact:

Post by KimmoA »

Jan Paul wrote:
KimmoA wrote: 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.
:?
Textfiles are always show "as-is" into any browser without ANY formatting. Case closed :?

I you need a text-based user agreement, make an HTML version and a PDF version. Everyone could see the HTML version and can keep a PDF version for downloading (if they need this).
I do not see any reason to not make the user agreement into an HTML file over a text file. Every OS can handle HTML files.

Regards,
Jan Paul
Sorry, but you're wrong. "As-is" can be with linebreaks (of course!).

I want to make linebreaks for every nth char, unless it's in the middle of a word.

Why doesn't anybody understand me or read what I say? :(
User avatar
Jan Paul
Posts: 21
Joined: Mon Apr 28, 2003 1:24 pm
Location: The Netherlands

Post by Jan Paul »

Hi KimmoA,

I understand your frustration :? .

"As-is" shows the textfile as it is line-breaked in the original text file.
If line 1 has an EOL on the 101th position, there the line breaks in the browser.
If the second line has an EOL on the 87th position, there the line breaks in the browser.
If the line has an EOL on the 1000000th position, there the line breaks in the browser so you get a very, very long line.

I think I understand your question ok. If you want to have a line break on ie every 80th column of your file, you have to manipulate the file.

This you can do by doing a regular expression replacement and inserting a hard EOL into the 80th position of every line. Maybe there is even a regular expression to take in account that this break must be before the last word before the 80th position. Look into the regular expressions for this (do a search on this forum or google for this).

So this is a regex question. Can some of the regex "gurus" on this forum take a look at this?

Regards,
Jan Paul
KimmoA
Posts: 17
Joined: Thu Jan 06, 2005 2:51 am
Location: Sweden
Contact:

Post by KimmoA »

Jan Paul wrote:Hi KimmoA,

I understand your frustration :? .

"As-is" shows the textfile as it is line-breaked in the original text file.
If line 1 has an EOL on the 101th position, there the line breaks in the browser.
If the second line has an EOL on the 87th position, there the line breaks in the browser.
If the line has an EOL on the 1000000th position, there the line breaks in the browser so you get a very, very long line.

I think I understand your question ok. If you want to have a line break on ie every 80th column of your file, you have to manipulate the file.

This you can do by doing a regular expression replacement and inserting a hard EOL into the 80th position of every line. Maybe there is even a regular expression to take in account that this break must be before the last word before the 80th position. Look into the regular expressions for this (do a search on this forum or google for this).

So this is a regex question. Can some of the regex "gurus" on this forum take a look at this?

Regards,
Jan Paul
Exactly! Now we're communicating. :)
KimmoA
Posts: 17
Joined: Thu Jan 06, 2005 2:51 am
Location: Sweden
Contact:

Post by KimmoA »

Now I have made my own little ugly hack.

I'm gonna share it with anyone who wants it...

Requirements: PHP with CLI on the local machine.

1) Download http://servy.kimmoa.se/tmp/wordwrap.phps.
2) Put it in c:\test\wordwrap.php.
3) Run "php c:\test\wordwrap.php <file>".

I made a quick tool link in my TextPad to run this. I don't know how to send this "file" to you, so I'll just tell you how to do it:

1) Make a new "tool"/shortcut.
2) Use "php c:\test\wordwrap.php $file" in the parameters box.

Now, when you run this shortcut while editing a file in TextPad, it will be updated with 80 chars max. per line! :-)

I hope that someone finds this useful...
KimmoA
Posts: 17
Joined: Thu Jan 06, 2005 2:51 am
Location: Sweden
Contact:

Post by KimmoA »

I guess that nobody else needed it :(
wnent
Posts: 12
Joined: Mon Aug 15, 2005 9:34 pm
Location: Fort Collins, CO
Contact:

Post by wnent »

A little belated, but I could have used that file if it still existed. I did eventually figure out how to do this pretty easily in TextPad though, and thought I'd put it here, since I read this whole thing hoping for an answer.

1. Turn off Word-Wrap if its on (this WON'T work if its on)
2. Go to Configure -> Preferences
3. Assuming your using a .txt file, drop down the Document Classes section in the left menu and select Text
4. In the right window, check the box for "Word wrap long lines", and select the option below it to "Save with hard breaks".
5. Click OK

Assuming you don't have the "Word break at column number:" box below the right window selected, the text will wrap with however wide the text-editing area in TextPad is. Save the file, and then undo the above unless you always want it to work this way. I was just using this for a one-time save.

A couple notes:
If you save the file this way, you can't go back to no line breaks without editing the file with some regular expressions, unless you keep the file open in TextPad and hit ctrl-z to undo it and save it as something else without the breaks.

If you didn't make any changes to the file prior to trying this and try to save it, it won't save the breaks, because TextPad doesn't think anything has changed. Make a minor change, save it, and undo the change and save it again.

Hope that helps someone,

Kevin
Post Reply