Contents Previous Next

## %!include command

The `include` command is used to paste the contents of an external file into the source document body. It is not a config, but a command, and it is valid on the document Body Area.

The `include` command is useful to split a large document into smaller pieces (like chapters in a book) or to include the full contents of an external file into the document source. Sample:

    My first book
    Dr. John Doe
    1st Edition

    %!include: intro.t2t
    %!include: chapter1.t2t
    %!include: chapter2.t2t
    ...
    %!include: chapter9.t2t
    %!include: ending.t2t

You just inform the filename after the `%!include` string. The optional target specification is also supported, so this is valid either:

    %!include(html): file.t2t

Note that include will insert the file Body Area into the source document. The included file Header and Config Areas are ignored. This way you can convert the included file alone or inside the main document.

But there's another three types of include:

- Verbatim include
- Raw include
- Tagged include

The Verbatim type includes a text file preserving its original spaces and formatting, just like if the text was inside the txt2tags Verbatim area (```). To specify this type, enclose the filename with backquotes:

    %!include: ``/etc/fstab``

The Raw type includes a text file as is, not trying to find and parse txt2tags marks on it, just like if the text was inside the Raw area ("""). To specify this type, enclose the filename with double quotes:

    %!include: ""nice_text.txt""

And the Tagged type is passed directly to the resulting document, with NO parsing or escaping performed by txt2tags. This way you can include additional tagged parts to your document. Useful for default header or footer information, or more complicated tagged code, unsupported by txt2tags:

    %!include(html): ''footer.html''

Note that the filename is enclosed with single quotes. As the text inserted is already parsed, you should specify the target to avoid mistakes.

Contents Previous Next