Contents Previous Next

Part VI - Mastering Macros

Macros are special purpose keywords, that are expanded on conversion time. They are used to insert dynamic information, for example the current date or information about the document source.

A macro is represented by the %% chars followed by its name, such as %%date. Some macros do accept an optional formatting string inside parenthesis, right after the macro name, such as %%date(%Y-%m-%d). This format string mixes common text with special directives, identified by a percent sign % followed by an identification character. If no format string is given, the default format is used.

Macro NameExpands to...Default Format
%%dateThe current date%Y%m%d
%%mtimeThe source file modification time %Y%m%d
%%infileThe source file path%f
%%outfileThe output file path%f
%%tocThe document TOC (Table of Contents) -

General rules:

Full example (bold text are expanded macros):

This is the Txt2tags User Guide, converted to html by txt2tags from the userguide.t2t source file. The conversion was done at 2010-11-04 08:09:04, but the last change on the source document was made on 2010-10-31 00:26:16. Both source and converted file reside on the userguide directory.

Contents Previous Next