| Author: | Mark Nodine |
|---|---|
| Contact: | mark.nodine@mot.com |
| Revision: | 1.2 |
| Date: | 2005-05-31 |
| Copyright: | This document has been placed in the public domain. |
/bin
This document gives the description and usage for the trip parser. It is compiled by running trip -h using a system:: directive.
This program converts the DocUtils reStructuredText or Document Object Model (DOM) (aka pseudo-XML) formats into an output format. The default output format is HTML, but different formats can be specified by using different writer schemas.
Usage: trip [options] file(s)
| -d | Print debugging info on STDERR. May be used multiple times to get more information. |
| -h | Print full usage help |
| -w <writer> | |
| Process the writer schema from <writer>.wrt (default 'html') | |
| -D var[=val] | Define a variable that affects parsing (may be multiple) |
| -W var[=val] | Define a variable that affects a writer (may be multiple) |
| -V | Print version info |
Available writers: dom, html, index, latex, toc, xref.
| -D align=<0|1> | |
| Allow inferring right/center alignment in single line simple table cells (default is 1). | |
| -D entryattr=<text> | |
| Specifies attributes to be passed to table entry (default is ''). Note: this option can be changed on the fly within a table by using a perl directive to set $main::opt_D{entryattr}. | |
| -D includeext=<text> | |
| A colon-separated list of extensions to check for included files. Default is ":.rst:.txt". | |
| -D includepath=<text> | |
| A colon-separated list of directories for the include directive to search. The special token "<.>" represents the directory of the file containing the directive (which may not be the same as the directory in which trip is invoked, ".". Default is "<.>". | |
| -D nestinline[=<0|1>] | |
| Specify whether to allow nesting of inline markup. There are some limitations, like strong cannot be nested within emphasis. Default is 1 (1 if specified with no value). | |
| -D perlpath=<text> | |
| A colon-separated list of directories to search for Perl modules. The special token "<INC>" represents the default Perl include path. Default is "<INC>". | |
| -D report=<level> | |
| Set verbosity threshold; report system messages at or higher than <level> (by name or number: "info" or "1", warning/2, error/3, severe/4; also, "none" or 5). Default is 2 (warning). | |
| -D rowattr=<text> | |
| Specifies attributes to be passed to table rows (default is ''). Note: this option can be changed on the fly within a table by using a perl directive to set $main::opt_D{rowattr}. | |
| -D source=<text> | |
| Overrides the file name as the source. | |
| -D tableattr=<text> | |
| Specifies attributes to be passed to tables (default is 'class="table" frame="border" rules="all"'). Note: this option can be changed on the fly to have tables with different characteristics by using a perl directive to set $main::opt_D{tableattr}. | |
| -D tabstops=<num> | |
| Specifies that tab characters are assumed to tab out to every <num> characters (default is 8). | |
| -D xformoff=<regexp> | |
| Turns off default transforms matching regexp. (Used for internal testing.) | |
| -D generator=<0|1> | |
| Include a "Generated by" credit at the end of the document (default is 1). | |
| -D date=<0|1> | |
| Include the date at the end of the document (default is 0). | |
| -D time=<0|1> | |
| Include the date and time at the end of the document (default is 1, overrides date if 1). | |
| -D source_link=<0|1> | |
| Include a "View document source" link (default is 1). | |
| -D source_url=<URL> | |
| Use the supplied <URL> verbatim for a "View document source" link; implies -D source_link=1. | |
| -D keep_title_section | |
| Keeps the section intact from which the document title is taken. | |
Executes its argument as a perl expression and returns its content if the perl expression is true. The content is interpreted as reStructuredText. It has no options. It processes the following defines:
| -D perl='perl-code' | |
Specifies some perl code that is executed prior to evaluating the first perl directive. This option can be used to specify variables on the command line; for example: -D perl='$a=1; $b=2' defines constants $a and $b that can be used in the perl expression. | |
| -D trusted | Must be specified for if directives to use any operators normally masked out in a Safe environment. This requirement is to prevent an if directive in a file written elsewhere from doing destructive things on your computer. |
Executes perl code and interpolates the results. The code can be contained either in the arguments or the contents section (or both). It has an option which determines how the returned value is interpreted:
If this option is not present, the return value is interpreted based on its type. If you return a text string, the text is interpreted as reStructuredText and is parsed again. If you return an internal DOM object (or list of them), the object is included directly into the parsed DOM structure. (This latter option requires knowledge of trip internals, but is the only way to create a pending DOM object for execution at transformation time rather than parse time.)
The perl directive defines the following global variables:
The following defines are processed by the perl directive:
| -D perl='perl-code' | |
Specifies some perl code that is executed prior to evaluating the first perl directive. This option can be used to specify variables on the command line; for example: -D perl='$a=1; $b=2' defines constants $a and $b that can be used in a perl block. | |
| -D trusted | Must be specified for perl directives to use any operators normally masked out in a Safe environment. This requirement is to prevent a perl directive in a file written elsewhere from doing destructive things on your computer. |
Executes a system (shell) command and interpolates the results. It has an option which determines how the returned value is interpreted:
If this option is not present, the return value is interpreted as reStructuredText and is parsed again.
Any error returned by the shell generates a level 3 error message. To see the output of a command that is expected to generate an error, do:
.. system:: <your command> 2>&1 | cat
The following defines are processed by the system directive:
| -D trusted | Must be specified for system directives to be processed. This requirement is to prevent a system directive in a file written elsewhere from doing destructive things on your computer. |
This writer dumps out the internal Document Object Model (DOM, also known as a doctree) in an indented format known as pseudo-XML. It is useful for checking the results of the parser or transformations. It recognizes the following defines:
| -W nobackn | Disables placing "\n\" at ends of lines that would otherwise end in whitespace. |
This writer creates HTML output. It uses the following output defines:
| -W bodyattr=<text> | |
| Specifies attributes to be passed to the <body> tag (default is ''). | |
| -W footnote_backlinks=<0|1> | |
| Enable backlinks from footnotes and citations to their references if 1 (default is 1). | |
| -W html_prolog=<0|1> | |
| Generate file prolog for XHTML if 0 or HTML if 1 (default is 0). | |
| -W stylesheet=<URL> | |
| Specify a stylesheet URL, used verbatim (default is "http://docutils.sourceforge.net/tools/stylesheets/default.css"). | |
| -W link_target=<expr> | |
| An expression that determines what the target frame will be in link references. The link URL is available in $_ so that the target frame can depend upon the URL (default is ""). | |
This writer dumps index entries from one or more input files out in reST format. An index is either an inline internal target or an indirect target that points to an inline internal target. The index writer sorts indices from all input files and put them into a table. Each row of the table contains an index entry and the location of the entry in the html version of the source file. An entry is also a reference to the definition in the corresponding html file.
This writer uses the following output defines:
| -W file_suffix=<suffix> | |
| Specify a file suffix to be used for the html version of the source files (default is "html"). | |
| -W filename_ext=<ext> | |
| Specify an extension to the filename, (e.g. "_main") so the location of targets becomes <file><ext>.<suffix> (default is ""). | |
| -W short_titles=<0|1> | |
| Specify that short titles should be used in the index (default is 1). | |
This writer creates an output in LaTeX format. It uses the following output defines:
| -W caption=<after|before> | |
| Specify that a figure caption should appear after or before the figure (default is "after"). | |
| -W documentstyle=<text> | |
| Specify documentstyle for the output (default is "article"). | |
| -W documentstyle_opts=<text> | |
| Specify the options for the documentstyle command (default is ""). | |
| -W footer[=1] | If 1, specify that the footer decoration generated by the RST transform should be included in the document (default is 0). |
| -W footnote_links[=1] | |
| If 1, specify that link URIs should be placed into footnotes (default is 0). | |
| -W index[=1] | If 1, specify that an index should be created from inline targets and indirect references to them (default is 0). |
| -W inputs=<list> | |
| Specify comma-separated list of files to \input | |
| -W max_unwrapped_colsize | |
| The maximum length of a string in a column of a table without forcing the width of the column and turning on wrapping for the entry. Setting it to 0 ensures that all tables will be exactly the width of the text, even if the table's natural width may be smaller. Setting it too large may result in tables that overflow the column boundary (default is 8). | |
| -W sidebar=<margin|float> | |
| Whether a sidebar should be processed as a paragraph in the margin or as a floating box within the text. Processing as a margin paragraph requires that \marginparwidth have a reasonable value and may require a raw directive with a \vspace -<dist> at the top to keep it from running off the page (default is "float"). | |
There are a number of commands defined which specify default styles for rendering various items. These default styles can be overridden by putting \renewcommand definitions for them into some file.tex and then invoking with -W inputs=file. These commands are
It is probably easiest to define these by first creating a .tex file with the writer and then copying the definition you want to modify from the top of the generated file into your style file, changing the "\newcommand" to "\renewcommand" and supplanting the definition.
This writer creates table of content (TOC) for one or more reStructuredText documents. The output includes section headers from the source files organized into lists, one per top level section. The TOC entries are references to the corresponding sections in the source documents.
This writer uses the following output defines:
| -W file_suffix=<suffix> | |
| Specify a file suffix to be used as the targets of TOC entries (default is "html"). | |
| -W filename_ext=<ext> | |
| Specify an extension to the filename, (e.g. "_main") so the file location of targets becomes <file><ext>.<suffix> (default is ""). | |
| -W depth=<positive_integer> | |
| Specify the depth of TOC, with 1 corresponding to the top level sections (default is 99). | |
| -W symbol=<header_marking_character> | |
| If specified, the writer uses the symbol to create additional headers for the document titles. (default is "", no headers created). This output define overwrites -W exclude_top=1. If a document does not have a title, use the document source bare name instead. | |
| -W include_noheader=<0|1> | |
| If set to 1, the writer includes in the TOC the document source bare name for any document that does not have a header (default is 0, do not include). | |
| -W exclude_top=<0|1> | |
| Specify whether the top level section headers should be excluded from the TOC (default is 0, do not exclude). This has no effect if -W symbol='<char>' is present. | |
| -W top_in_list=<0|1> | |
| Specify whether the top level section headers should be part of the list with other section headers (default is 0, top level header being outside of the list). This has no effect if the top level headers are excluded. | |
This writer exports cross reference targets defined in the source reStructuredText (reST) file. The output is in reST format and includes:
All non-anonymous internal targets, exported as
.. <targetName>: <sourceFileName><ext>.<suffix>#<targetID>
All citations, exported as:
.. <citationName>: <sourceFileName><ext>.<suffix>#<citationID>
Substitution definitions that have the same names as internal targets but do not, directly or indirectly through substitution references, define internal target or refer to external references or footnotes.
Definition of substitutions referred to by the substitutions exported according to 3. Substitution definitions are exported as defined in the source file.
This writer uses the following output definitions:
| -W file_suffix=<suffix> | |
| Specify a file suffix to be used for exporting the cross reference targets (default is html). | |
| -W filename_ext=<ext> | |
| Specify an extension to the filename, (e.g. "_main") so the file location of targets becomes <file><ext>.<suffix> (default is ""). | |
| -W file_path=<dir> | |
| Specify additional path information for the target file (default is "") | |
| -W sprintf=<string> | |
| Specify an sprintf string for formatting the output definitions (default is "%s"). | |