Re: ascii text format

2008-11-21 Thread Polytropon
On Fri, 21 Nov 2008 10:49:16 +, pwn [EMAIL PROTECTED] wrote:
 what software/tool can i use for format my *.txt? there is command on 
 VIM like set textwidth but this is not suitable for me. any help i 
 appreciate.

Judging from your example text, what you're searching for is a
tool to format your text in paragraph mode (block mode) using
spaces between the words.

I'm not sure if there's already a tool on FreeBSD that does the
trick, but you can surely write a simple awk script to do it.
I'd suggest something like this: Break each input line into
words using the space character as separator. Then, iterate
over these words and put spaces after each word; repeat this
until you've reached the desired text width. This should be
relatively easy to accomplish. Furthermore, you can add an
empty string before each output line in order to create a
left margin.




-- 
Polytropon
From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: ascii text format

2008-11-21 Thread Jonathan McKeown
On Friday 21 November 2008 12:49:16 pwn wrote:
 algouth this is not a freebsd specific text, i need to format some texts
 under freebsd for they appear in the center of the page when opened in a
 browser, but i dont want to use HTML for format them, i just want to add
 tabulation to my *.txt.
 what software/tool can i use for format my *.txt? there is command on
 VIM like set textwidth but this is not suitable for me. any help i
 appreciate.
 i add an example on a temporary host for make sure all understand.
 (i need to format the text for he appear like the example good.txt)
 http://one.xthost.info/temphost/good.txt
 http://one.xthost.info/temphost/bad.txt

You seem to be fighting against your tools rather than working with them - the 
browser will strip out your whitespace and reflow your text anyway unless you 
prevent it somehow (pre tags?) so you might be better off just using 
HTML/CSS to control the format.

However, you could look at various tools for processing text, depending 
exactly what you're trying to do: the manpages for fmt, groff, and pr might 
all offer some ideas.

Jonathan
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: ascii text format

2008-11-21 Thread pwn

Jonathan McKeown wrote:

On Friday 21 November 2008 12:49:16 pwn wrote:
  

algouth this is not a freebsd specific text, i need to format some texts
under freebsd for they appear in the center of the page when opened in a
browser, but i dont want to use HTML for format them, i just want to add
tabulation to my *.txt.
what software/tool can i use for format my *.txt? there is command on
VIM like set textwidth but this is not suitable for me. any help i
appreciate.
i add an example on a temporary host for make sure all understand.
(i need to format the text for he appear like the example good.txt)
http://one.xthost.info/temphost/good.txt
http://one.xthost.info/temphost/bad.txt



You seem to be fighting against your tools rather than working with them - the 
browser will strip out your whitespace and reflow your text anyway unless you 
prevent it somehow (pre tags?) so you might be better off just using 
HTML/CSS to control the format.


However, you could look at various tools for processing text, depending 
exactly what you're trying to do: the manpages for fmt, groff, and pr might 
all offer some ideas.


Jonathan
  



yes, i want that the text appears displayed such as manpages like, how 
can i accomplish this task?



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]

  


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: ascii text format

2008-11-21 Thread Mel
On Friday 21 November 2008 16:53:09 pwn wrote:
 Jonathan McKeown wrote:
  On Friday 21 November 2008 12:49:16 pwn wrote:
  algouth this is not a freebsd specific text, i need to format some texts
  under freebsd for they appear in the center of the page when opened in a
  browser, but i dont want to use HTML for format them, i just want to add
  tabulation to my *.txt.
  what software/tool can i use for format my *.txt? there is command on
  VIM like set textwidth but this is not suitable for me. any help i
  appreciate.
  i add an example on a temporary host for make sure all understand.
  (i need to format the text for he appear like the example good.txt)
  http://one.xthost.info/temphost/good.txt
  http://one.xthost.info/temphost/bad.txt
 
  You seem to be fighting against your tools rather than working with them
  - the browser will strip out your whitespace and reflow your text anyway
  unless you prevent it somehow (pre tags?) so you might be better off
  just using HTML/CSS to control the format.
 
  However, you could look at various tools for processing text, depending
  exactly what you're trying to do: the manpages for fmt, groff, and pr
  might all offer some ideas.
 
  Jonathan

 yes, i want that the text appears displayed such as manpages like, how
 can i accomplish this task?


Manpages use advanced formatting codes. You can achieve some result, by:

fmt -c 70 80 bad.txt

But anything further you will have to edit the text. Maybe you can wrap some 
formatting codes around the text for the tbl(1) program. But I agree with 
Jonathan - it's easier to reformat the text using HTML code and some of that 
can be done with a script/parser, providing the text uses some degree of 
consistency.
-- 
Mel

Problem with today's modular software: they start with the modules
and never get to the software part.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: ascii text format

2008-11-21 Thread Giorgos Keramidas
On Fri, 21 Nov 2008 10:49:16 +, pwn [EMAIL PROTECTED] wrote:
 algouth this is not a freebsd specific text, i need to format some texts
 under freebsd for they appear in the center of the page when opened in a
 browser, but i dont want to use HTML for format them, i just want to add
 tabulation to my *.txt.
 what software/tool can i use for format my *.txt? there is command on
 VIM like set textwidth but this is not suitable for me. any help i
 appreciate.

 i add an example on a temporary host for make sure all understand.
 (i need to format the text for he appear like the example good.txt)

 http://one.xthost.info/temphost/good.txt
 http://one.xthost.info/temphost/bad.txt

It looks like you want groff(1) (or some other typesetting system that
can generate plain text output, like GNU Texinfo).

The groff utility and its associated formatting toolchain is relatively
easy to learn and it can produce output like:

,---
|
|
|
|  Some Title
|
|
|  A. U. Thor
|
|13 Friday St.
|Someplace (SP)
|
|
|   ABSTRACT
|
|   Dreaming  of space-flight, and predicting its
|  future, have always been favorite pastimes of sci-
|  ence fiction. In my first science column for FSF,
|  I can't resist the urge to  contribute  a  bit  to
|  this grand tradition.
|
|   A  science-fiction  writer in 1991 has a pro-
|  found advantage over the genre's pioneers.   Nowa-
|  days,  space-exploration  has  a past as well as a
|  future.  ``The conquest of space'' can  be  judged
|  today,  not  just  by  dreams,  but by a real-life
|  track record.
|
|
| 1.  Introduction
|
|  Here's the main text.
|
| 2.  Getting Started
|
|  This is the first paragraph of a new section.  The sec-
| tion titles are automatically indented, numbered and format-
| ted with the default style of ``numbered  headers''  by  the
| groff_ms(7) macros themselves.
|
|  Note  how  the  first  line  of  each paragraph is also
| indented a bit to the right.  This is the default  style  of
| groff_ms(7)  output,  but  you can easily tune and tweak the
| defaults to match pretty much any style you prefer.
|
|
`---

from relatively easy to prepare input text files.  The text shown above
has been produced by the following ``document source'', written in the
style expected by the groff_ms(7) formatting macros:

.TL
Some Title
.AU
A.\ U.\ Thor
.sp 1
.AI
13 Friday St.
Someplace (SP)
.AB
Dreaming of space-flight, and predicting its future, have always been
favorite pastimes of science fiction. In my first science column for
.I FSF ,
I can't resist the urge to contribute a bit to this grand tradition.
.PP
A science-fiction writer in 1991 has a profound advantage over the
genre's pioneers.  Nowadays, space-exploration has a past as well as a
future.  ``The conquest of space'' can be judged today, not just by
dreams, but by a real-life track record.
.AE
.\ ===
.\ This is a comment at the start of a new section.
.\ ===
.ds RH Introduction
.NH
Introduction
.PP
Here's the main text.
.\ ===
.\ This is a comment at the start of a new section.
.\ ===
.ds RH Getting Started
.NH
Getting Started
.PP
This is the first paragraph of a new section.
The section titles are automatically indented, numbered and formatted
with the default style of ``numbered headers'' by the
.B groff_ms(7)
macros themselves.
.PP
Note how the first line of each paragraph is also indented a bit to the
right.  This is the default style of groff_ms(7) output, but you can
easily tune and tweak the defaults to match pretty much any style you
prefer.

If this looks interesting, you can find a *lot* of information about
groff and its macro packages at the following places:

 1. In the `Info manual' of groff itself.  This is already installed as
part of your base system, and you can start reading it by typing:

  % info groff

 2. At the web page of groff itself:

  http://www.gnu.org/software/groff/#documentation

 3. At the troff.org pages:

  http://troff.org/

These pages are about groff's ancestor: the `troff' formatter.  They
include various links about online troff/groff resources.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send 

Re: ascii text format

2008-11-21 Thread Giorgos Keramidas
On Fri, 21 Nov 2008 15:53:09 +, pwn [EMAIL PROTECTED] wrote:
 yes, i want that the text appears displayed such as manpages like, how
 can i accomplish this task?

The manpages are written in groff.  More specifically, they are written
in a format that may be formatted by the `mdoc' macros of groff; the set
of groff macros described in the groff_mdoc(7) manpage.

See my other post about using groff and a specially formatted `input
file' to produce text output similar to the manpage look  feel :)

The `mdoc' macro package is just _one_ of the available sets of macros
for formatting text with groff.  Check out the groff wiki at

http://www.port.de/cgi-bin/groff/GroffMacroPackages

for information about the standard macro packages included with groff.

The `extras' page at

http://www.port.de/cgi-bin/groff/GroffExtras

has pointers to other, non-standard macro packages.  This may be a bit
interesting too.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: ascii text format

2008-11-21 Thread Matthias Apitz
El día Friday, November 21, 2008 a las 03:53:09PM +, pwn escribió:

 Jonathan McKeown wrote:
 On Friday 21 November 2008 12:49:16 pwn wrote:
   
 algouth this is not a freebsd specific text, i need to format some texts
 under freebsd for they appear in the center of the page when opened in a
 browser, but i dont want to use HTML for format them, i just want to add
 tabulation to my *.txt.
 what software/tool can i use for format my *.txt? there is command on
 VIM like set textwidth but this is not suitable for me. any help i
 appreciate.
 i add an example on a temporary host for make sure all understand.
 (i need to format the text for he appear like the example good.txt)
 http://one.xthost.info/temphost/good.txt
 http://one.xthost.info/temphost/bad.txt
 
 
 You seem to be fighting against your tools rather than working with them - 
 the browser will strip out your whitespace and reflow your text anyway 
 unless you prevent it somehow (pre tags?) so you might be better off 
 just using HTML/CSS to control the format.
 
 However, you could look at various tools for processing text, depending 
 exactly what you're trying to do: the manpages for fmt, groff, and pr 
 might all offer some ideas.
 
 Jonathan
   
 
 
 yes, i want that the text appears displayed such as manpages like, how 
 can i accomplish this task?

what about:

$ groff -Tascii  bad.txt

SOME TITLE



Dreaming  of space-flight, and predicting its future, have always
been favorite pastimes of science fiction. In  my  first  science
column  for  FSF, I can't resist the urge to contribute a bit to
this grand tradition.

A science-fiction writer in 1991 has a  profound  advantage  over
the  genre's  pioneers. Nowadays, space-exploration has a past as
well as a future. The conquest of space can  be  judged  today,
not just by dreams, but by a real-life track record.


and some more tweakings after that with sed, ...

matthias

-- 
Matthias Apitz
Manager Technical Support - OCLC GmbH
Gruenwalder Weg 28g - 82041 Oberhaching - Germany
t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211
e [EMAIL PROTECTED] - w http://www.oclc.org/ http://www.UnixArea.de/
b http://gurucubano.blogspot.com/
Q: What's the difference between an iphone and a freerunner?
A: One works but takes away your freedom, the other is free but needs your work.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: ascii text format

2008-11-21 Thread Daniel Molina Wegener

pwn escribió:
algouth this is not a freebsd specific text, i need to format some texts 
under freebsd for they appear in the center of the page when opened in a 
browser, but i dont want to use HTML for format them, i just want to add 
tabulation to my *.txt.
what software/tool can i use for format my *.txt? there is command on 
VIM like set textwidth but this is not suitable for me. any help i 
appreciate.

i add an example on a temporary host for make sure all understand.
(i need to format the text for he appear like the example good.txt)
http://one.xthost.info/temphost/good.txt
http://one.xthost.info/temphost/bad.txt

 [SNIP]

Well, try par, it's a port, use portinstall, pkg_add or another tool
to install it:
http://cvsweb.freebsd.org/ports/textproc/par

I was using it with vim and mutt to format mail some years ago ;)

Best regards,
--
.O. | Daniel Molina Wegener   | C/C++ Coder
..O | dmw [at] coder [dot] cl | FOSS Developer
OOO | FreeBSD  Linux User| Standards Basis


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]