ascii text format

Giorgos Keramidas keramida at ceid.upatras.gr
Fri Nov 21 08:25:19 PST 2008


On Fri, 21 Nov 2008 10:49:16 +0000, pwn <pwnedomina at gmail.com> 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 F&SF,
|      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 F&SF ,
    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.



More information about the freebsd-questions mailing list