txt2tags(1) man page


txt2tags - text formatting and conversion tool


txt2tags [options] [FILE...]


txt2tags reads a text file with minimal markup and convert it to: ASCII Art, AsciiDoc, Creole, DocBook, DokuWiki, Google Code Wiki, HTML, LaTeX, Lout, MagicPoint, Man page, MoinMoin, PageMaker, Plain Text, PmWiki, SGML, Wikipedia and XHTML.

This man page was created by txt2tags from a simple text file. The same text file is also converted to HTML for the online version of this manual.

ONE source, MULTI targets - http://txt2tags.org


  Headers           First 3 lines of the source file
  Title             = words =
  Numbered title    + words +
  Comment           % comments
  Separator line    -----------------------...
  Strong line       =======================...
  Image             [filename.jpg]
  Link              [label url]
  Bold              **words**
  Italic            //words//
  Underline         __words__
  Strike            --words--
  Monospaced        ``words``
  Raw               ""words""
  Tagged            ''words''
  Paragraph         words
  Quote             <TAB>words
  List              - words
  Numbered list     + words
  Definition list   : words
  Table             | cell1 | cell2 | cell3...
  Verbatim line     ``` words
  Raw line          """ words
  Tagged line       ''' words
  Verbatim block    ```
  Raw block         """
  Tagged block      '''


Define PATTERN as the pattern of characters used to compose the ASCII Art decorations, in the following order: corner, border, side, bar1, bar2, level2, level3, level4, level5. The default pattern value is +-|-==-^". This option is only used by the ASCII Art target.

-C, --config-file=FILE
Read configuration from the external file FILE. The configuration must be on the %!keyword:value format. See SETTINGS section for details.

Improves the generated HTML/XHTML code to be used with CSS files. Tag attributes are removed, presentation tags are avoided, header is composed by H1, H2 and H3 tags, new DIVs are created: #header, #body, .toc.

Insert CSS file contents inside HTML/XHTML headers. Use --style to specify a CSS file to be read.

Print all the configuration found and exit.

Print the document source, with includes (%!include) expanded.

Inform the character set (file encoding) used by the source document. Examples are UTF-8 and iso-8859-1. The encoding is not changed during conversion, so the output document will have the same encoding as the sources.

Invoke Graphical Tk Interface.

-h, --help
Print help information and exit.

-H, --no-headers
Suppress header and footer from the output. Only the contents (body) will be shown.

Show header and footer in the output. Default is ON.

Set the output's height to NUM rows. This option is only used by the ASCII Art target, when also using --slides.

-i, --infile=FILE
Set FILE as the input file name, the source document. Use '-' to read the sources from the STDIN.

Hide emails from spam robots. Removes @ and dots. The address foo@bar.com turns to <foo (a) bar com>.

-n, --enum-title
Turn on automatic numbering for titles. They will be prefixed by 1, 1.1, 1.1.1, ...

Cancel the --dump-config action.

Cancel the --dump-source action.

Clear the encoding setting.

Turn off the automatic numbering for titles.

Clear all the previous infile declarations.

Cancel the --targets action.

Turn off the email masking feature.

Clear the previous outfile declaration.

Show messages, turning off the --quiet option.

Do not read the user configuration file ~/.txt2tagsrc.

Turn off the slides feature.

Clear all the style settings.

Remove the Table of Contents from the output.

Turn off the --toc-only action.

-o, --outfile=FILE
Set FILE as the output file name. Use '-' to send the results to STDOUT.

-q, --quiet
Quiet mode. Suppress all output, except errors.

Read the user configuration file ~/.txt2tagsrc. Default is ON.

Format output as presentation slides. This option is only used by the ASCII Art target.

Use FILE as the document's style file. Used to define CSS files for HTML/XHTML documents and packages for LaTeX. This option can be used multiple times to include multiple files.

-t, --target=TYPE
Set the output document format to TYPE. Some popular types are: html, xhtml, tex, man, txt. Use the --targets option to see all the available formats.

Print a list of all the available targets and exit.

Include an automatic Table of Contents (TOC) to the output, between the Header and the Body. You can also specify the TOC position using the %%TOC macro.

Set the maximum TOC level to NUM. All titles deeper than NUM will not be included in the Table of Contents.

Print the Table of Contents and exit.

-v, --verbose
Print informative messages during conversion. This option can be used multiple times to increase the number of messages shown.

-V, --version
Print program version and exit.

Set the output's width to NUM columns. This option is only used by the ASCII Art target.


The source files are usually identified by the .t2t extension (such as myfile.t2t). You may have three areas inside your sources:

Header (optional)
The first three lines of the file. Leave the first line blank if you don't need headers. Used for document title, author, version and date information.

Settings (optional)
Begins right after the Header (4th or 2nd line) and ends when the Body area starts. Used for settings (configurations) in the %!keyword:value format.

Begins at the first valid text line (not comment or setting) after the Header area and goes until the end of the document. Used for the document contents.


Settings let you customize txt2tags, they're similar to options. They can be used at: source document's Settings area, ~/.txt2tagsrc file, external file called with --config-file.

Set the output format, just like --target. Example:
  %!target: html

Set the default options to each target. You must use the command line options. Example:
  %!options(html): --toc --toc-level 3 --css-sugar

Include configurations from an external file into the current, just like --config-file. Example:
  %!includeconf: myconfig.t2t

Set a style file for the document, just like --style. Can be used multiple times. Example:
  %!style: colors.css

Set the character set used by the document, just like --encoding. Example:
  %!encoding: UTF-8

Input search/replace filter used to change the Body of the source document BEFORE any parsing by txt2tags. Search uses Python regular expressions. Example:
  %!preproc:  "JJS"  "John J. Smith"

Output search/replace filter used to change the generated document AFTER all the txt2tags processing. Search uses Python regular expressions. Example:
  %!postproc(html):  "<B>"  "<STRONG>"

If the same keyword appears more than once, the last found will be the one used (except: options, preproc and postproc, which are cumulative). Invalid keywords are ignored. The parsing order is: ~/.txt2tagsrc, source document's Config area, --config-file option.


Commands perform tasks during conversion time. They must be placed at the source document's Body.

%!csv: file.csv
Includes an external CSV file as a table.

%!include: file.t2t
Includes a txt2tags file in the document.

%!include: ``file.txt``
Includes a text file (verbatim) in the document.

%!include: ''file.html''
Includes an already tagged file in the document.


Macros are handy shortcuts to insert dynamic contents in your document. They must be placed at the source document's Body. Most macros can be customized with special directives, like %Y and %f. See the txt2tags User Guide for details.

Insert the current date. The default format is %%date(%Y%m%d), which gives YYYYMMDD.

Insert the source file path. The default format is %%infile(%f). Useful for footer links like [See source %%infile].

Insert the source file modification time. The default format is %%date(%Y%m%d), which gives YYYYMMDD.

Insert the output file path. The default format is %%outfile(%f). Useful for self mentioning like "This is the manpage.html file".

Specifies where the Table of Contents will be placed. You can even use it multiple times. Note that you must also use the --toc option.

Insert the txt2tags URL: http://txt2tags.org.

Insert the txt2tags name.

Insert the current version number of txt2tags (currently 2.6.).

Insert the target name being processed.

Insert the encoding name choosen.

Insert the command line used to generate the target document.

%%header1, %%header2, %%header3,
Insert the headers.


txt2tags -t html file.t2t

Convert to HTML, saving to file.html.

txt2tags -t html -o - file.t2t

Convert to HTML, sending results to STDOUT.

txt2tags -t html --toc file.t2t

Convert to HTML, including automatic Table Of Contents.

txt2tags -t html --toc --toc-level 2 -n file.t2t

Convert to HTML, with a two level Table of Contents and numbered titles.

txt2tags --toc-only file.t2t

Just show the Table of Contents, no conversion is done.

txt2tags -t html --css-sugar --style base.css --style ui.css file.t2t

Convert to HTML, preparing the resulting code to be used with CSS, and also include calls to two external CSS files.

txt2tags -t art --slides --width 80 --height 25 -o - file.t2t | more

Create ASCII Art presentation slides, ready to be shown in a 80x25 terminal screen/window.

(echo ; echo "**bold**") | txt2tags -t html -H -

Handy one-liner for quick tests using STDIN.

txt2tags -t html -o - file.t2t | tidy > file.html

Send results to STDOUT, then fine tune the code with an external program before saving the output file.


Default user configuration file.


If non-null, sets the full pathname for the default user configuration file.


Aurelio Jargas <<verde (a) aurelio net>>




Copyright (C) 2001-2019 Aurelio Jargas, GNU GPL v2

« txt2tags.org