Homepage(german)     Computer stuff [français]     [deutsch]

fortext

reformatting ascii-text

Download

fortext-0.04.tgz (8k) [The executable is stripped about 12K. The package contains the sources and a man-page template.]

(requires only the standard include files.)


Description

I frequently had to reformat ascii-texts I found somewhere in the net, especially in the usenet. The main problem always was to seperate the paragraphs with blank lines and then to reformat the single paragraphs. The latter can be done by every reasonable editor. The first has to done by hand.

fortext is a program which tries to guess the paragraphs and then reformats the text in one way or another according to the given options. Normally it reads from stdin and writes to stdout, but it can also read from files and write to files. Further informations can be taken from the manpage, which is produced by make.

An example: The following text was disfigured by several news-readers.

Of the Spirit
-------------
(c) Jasjit Singh, March 1999

The crew of the USS Voyager was celebrating.  They had 
just completed
another milestone in their long journey towards Earth, and 
everyone was in
a jovial mood.  A group of the senior staff agreed to head down 
to the mess
hall for their celebration.  On their way, Tom Paris and 
Seven of Nine
encountered Chakotay in the hallway.

"Chakotay, you'll be joining us in the mess hall?" inquired Paris.
Chakotay grinned but shook his head.
"I need to be getting back to my quarters," he replied.
"Its early still! Come on, have a drink with us," cajoled Paris.
"Thanks but I can't.  It is coming close to my meditation time," said
Chakotay, smiling politely.
"Ah, yes, the daily meditation," Paris nodded.  "You have been doing that
day in and day out, every day since I've known you.  Doesn't it get
repetitive?"
"Repetitive, no.  Customary, yes.  Beneficial, absolutely."
"I don't know, Chakotay.  We're in the twenty fourth century.  We have warp
drive.  We are out among the stars!  Is ancient religion really that
important any more?"

[...]

fortext, invoked without any options, produced the following output:


Of the Spirit ------------- (c) Jasjit Singh, March 1999

The crew of the USS Voyager was celebrating. They had just completed
another milestone in their long journey towards Earth, and everyone was in
a jovial mood. A group of the senior staff agreed to head down to the mess
hall for their celebration. On their way, Tom Paris and Seven of Nine
encountered Chakotay in the hallway.

"Chakotay, you'll be joining us in the mess hall?" inquired Paris. Chakotay
grinned but shook his head.

"I need to be getting back to my quarters," he replied.

"Its early still! Come on, have a drink with us," cajoled Paris. "Thanks
but I can't. It is coming close to my meditation time," said Chakotay,
smiling politely.

"Ah, yes, the daily meditation," Paris nodded. "You have been doing that
day in and day out, every day since I've known you. Doesn't it get
repetitive?"

"Repetitive, no. Customary, yes. Beneficial, absolutely."

"I don't know, Chakotay. We're in the twenty fourth century. We have warp
drive. We are out among the stars! Is ancient religion really that
important any more?"

[...]

But if the line containing the paragraph ending with "absolutely" was only some characters longer, fortext wouldn't had recognized it as own paragraph, but had joined it with the following lines.

fortext-0.02 is, as can be seen by the version number, one of my first attempts. So I don't know how much it is worth in practise. Some internal parameters still have to find their optimal values, or should at least be made configurable.

Copyright

All parts of the program are under the BSD-license.

System requirements

The program compiles with gcc and runs on my linux boxes (SuSE-6.4 and 7.2) and in a CygWin-environment under Windows, but it should be not too difficult to port it to other systems, C-libraries and compilers, the more so as the code is not large.


Homepage(german)     Computer stuff by Michael Becker, 10/2001. Last modification 12/2002