Contents Previous Next

The Three User Interfaces: Gui, Web and Command Line

As different users have different needs and environments, txt2tags is very flexible on how it runs.

There are three User Interfaces for the program, each one with its own purpose and features.

Graphical Tk Interface

Since version 1.0, there is a nice Graphical Interface, that works on Linux, Windows, Mac and others.

The program detects automatically if your system can display the interface, and it is launched when called with no arguments. One can force the Graphical Interface call with the --gui option. If some resources are missing, the program will tell.

Note: The Tkinter module is needed. As it comes with the standard Python distribution, you may already have it.

The interface is pretty simple and intuitive:

  1. You locate the source .t2t file on the disk and its options are loaded.

  2. If the target is still empty, you must choose one.

  3. Then there are some options you may choose, but none of them are required.

  4. Finally, press the "Convert!" button.

A nice option to check is the "Dump to screen", so you can check the resulting code on a separate window, no file is saved at all. When the code is OK, you uncheck it and the file will be saved.

The default interface colors can be changed on the ~/.txt2tagsrc file, using the %!guicolors settings. For example:

% set my own colors for the graphical interface (bg1, fg1, bg2, fg2)
%!guicolors: blue white brown yellow

Web Interface

The Web Interface is up and running on the Internet at http://txt2tags.sf.net/online.php, so you can use and test the program instantly, before download.

One can also put this interface on the local intranet avoiding to install txt2tags in all machines.

Command Line Interface

For command line power users, the --help should be enough:

Usage: txt2tags [OPTIONS] [infile.t2t ...]

  -t, --target=TYPE   set target document type. currently supported:
                      html, xhtml, sgml, tex, lout, man, mgp, wiki,
                      gwiki, doku, moin, pm6, txt
  -i, --infile=FILE   set FILE as the input file name ('-' for STDIN)
  -o, --outfile=FILE  set FILE as the output file name ('-' for STDOUT)
  -n, --enum-title    enumerate all title lines as 1, 1.1, 1.1.1, etc
  -H, --no-headers    suppress header, title and footer contents
      --headers       show header, title and footer contents (default ON)
      --encoding      set target file encoding (utf-8, iso-8859-1, etc)
      --style=FILE    use FILE as the document style (like HTML CSS)
      --css-sugar     insert CSS-friendly tags for HTML and XHTML targets
      --css-inside    insert CSS file contents inside HTML/XHTML headers
      --mask-email    hide email from spam robots. x@y.z turns <x (a) y z>
      --toc           add TOC (Table of Contents) to target document
      --toc-only      print document TOC and exit
      --toc-level=N   set maximum TOC level (depth) to N
      --rc            read user config file ~/.txt2tagsrc (default ON)
      --gui           invoke Graphical Tk Interface
  -q, --quiet         quiet mode, suppress all output (except errors)
  -v, --verbose       print informative messages during conversion
  -h, --help          print this help information and exit
  -V, --version       print program version and exit
      --dump-config   print all the config found and exit

Turn OFF options:
     --no-outfile, --no-infile, --no-style, --no-encoding, --no-headers
     --no-toc, --no-toc-only, --no-mask-email, --no-enum-title, --no-rc
     --no-css-sugar, --no-css-inside, --no-quiet

Example:
     txt2tags -t html --toc myfile.t2t

By default, converted output is saved to 'infile.<target>'.
Use --outfile to force an output file name.
If  input file is '-', reads from STDIN.
If output file is '-', dumps output to STDOUT.

Examples

Assuming you have written a file.t2t marked file, let's have some converting fun.

Convert to HTML$ txt2tags -t html file.t2t
The same, using redirection$ txt2tags -t html -o - file.t2t > file.html
.
Including Table Of Contents$ txt2tags -t html --toc file.t2t
And also, numbering titles$ txt2tags -t html --toc --enum-title file.t2t
.
Contents quick view$ txt2tags --toc-only file.t2t
Maybe enumerate them?$ txt2tags --toc-only --enum-title file.t2t
.
One liners from STDIN$ echo -e "\n**bold**" | txt2tags -t html --no-headers -
Testing Mask Email feature$ echo -e "\njohn.wayne@farwest.com" | txt2tags -t txt --mask-email --no-headers -
Post-convert editing$ txt2tags -t html -o- file.t2t | sed "s/<BODY .*/<BODY BGCOLOR=green>/" > file.html
Note: Since version 1.6 you can do pre and post processing with the %!preproc and %!postproc configuration filters.

Contents Previous Next