Internals of Prest

Author: Mark Nodine
Contact: mnodine@alum.mit.edu
Revision: 762
Date: 2006-01-27 11:47:47 -0600 (Fri, 27 Jan 2006)
Copyright: This document has been placed in the public domain.

Contents

This document extracts documentation from the internal Perl files.

Subroutines

Here are all the Perl subroutines used in the implementation of prest. This list is automatically generated by running perlsynopsis -l -m on the prest and *.pm files.

prest

main::main(): (prest, 94)

The main entry point. Parses command-line options, preprocesses the writer schema, causes the document(s) to be read, and calls the writer.

main::EncodingList(): (prest, 142)

Gets list of encodings

Arguments:
none
Returns:
list of writers

main::WriterList(): (prest, 153)

Gets list of writers

Arguments:
none
Returns:
list of writers

main::Usage($what): (prest, 166)

Extracts and prints usage information

Arguments:
type of usage, end marker for usage (optional)

Restructured.pm

Text::Restructured::new($class, $opt, $tool_id): (Restructured.pm, 318)

Creates a new Parser object

Arguments:
hash to reference of options, tool identifier

Text::Restructured::init($self, $doc, $filename): (Restructured.pm, 337)

INSTANCE METHOD. Processes defaults for -D defines and resets object variables between documents.

Arguments:
document DOM object, file name
Returns:
None
Sets instance vars:
SEC_LEVEL, SEC_DOM, TOPDOM SEC_STYLE, ANONYMOUS_TARGETS, REFERENCE_DOM, TARGET_NAME, ALL_TARGET_IDS, ALL_TARGET_NAMES MY_ROLES, MY_DEFAULT_ROLE

Text::Restructured::problematic($self, $text, $refid, $id): (Restructured.pm, 394)

INSTANCE METHOD. Returns a DOM object for a problematic with its ids.

Arguments:
message, reference id (optional), id (optional)
Returns:
DOM object, reference id, id

Text::Restructured::system_message($self, $level, $source, $lineno, $msg, $lit, %attr): (Restructured.pm, 407)

INSTANCE METHOD. Returns a DOM object for a system message.

Arguments:
severity level, source, line number, message, literal text, key/value pairs for additional attributes

Text::Restructured::BulletList($self, $para, $source, $lineno): (Restructured.pm, 429)

INSTANCE METHOD. Processes a bulleted list paragraph.

Arguments:
paragraph, source, line number
Returns:
processed paragraph, list of DOM objects and unprocessed paragraphs

Text::Restructured::Coalesce($self, $paras): (Restructured.pm, 457)

INSTANCE METHOD. Coalesces a series of similar paragraphs and divides initial paragraph for unexpected indents.

Argument:
reference to array of paragraphs
Returns:
None (but modifies the paragraphs referenced by the argument)

Text::Restructured::DefineRole($self, $role, $tag, %options): (Restructured.pm, 711)

INSTANCE METHOD. Defines a new role, optionally based upon an existing role

Arguments:
new role name, optional old role name, optional option key/values
Returns:
possible error message

Text::Restructured::DefinitionList($self, $para, $source, $lineno): (Restructured.pm, 742)

INSTANCE METHOD. Processes a definition list paragraph.

Arguments:
paragraph, source, line number
Returns:
processed paragraph, list of DOM objects and unprocessed paragraphs

Text::Restructured::Directive($self, $parent, $source, $lineno, $errmsgid, $dtext, $lit): (Restructured.pm, 818)

INSTANCE METHOD. Parses a directive and attaches it to a DOM if successful.

Arguments:
DOM object, source, line number, error message id, directive text, paragraph literal
Returns:
error flag, reference to array of DOM objects (possibly including input DOM), reference to array of unparsed paragraphs.

Text::Restructured::EnumList($self, $para, $source, $lineno): (Restructured.pm, 910)

INSTANCE METHOD. Processes a enumerated list paragraph.

Arguments:
paragraph, source, line number
Returns:
processed paragraph, list of DOM objects and unprocessed paragraphs

Text::Restructured::EnumType($self, $index): (Restructured.pm, 964)

INSTANCE METHOD. Given the initial index of an enumerated list, returns the enumeration type.

Arguments:
Initial index
Returns:
one of "arabic", "loweralpha", "upperalpha", "lowerroman", "upperroman" or "#" (for auto-enumerated)

Text::Restructured::EnumVal($self, $index, $enumtype): (Restructured.pm, 985)

INSTANCE METHOD. Given an index of an enumerated and the enumeration type, returns the index value.

Arguments:
Index, enumerated type
Returns:
number or -1 (for badly formatted Roman numerals/arabic)

Text::Restructured::Explicit($self, $parent, $para, $source, $lineno): (Restructured.pm, 1016)

INSTANCE METHOD. Processes an explicit markup paragraph.

Arguments:
parent, paragraph, source, line number
Returns:
processed paragraph, new parent, list of DOM objects and unprocessed paragraphs

Text::Restructured::FieldList($self, $para, $source, $lineno): (Restructured.pm, 1185)

INSTANCE METHOD. Processes a field list paragraph.

Arguments:
paragraph, source, line number
Returns:
processed paragraph, list of DOM objects and unprocessed paragraphs

Text::Restructured::HashifyFieldList($self, $text): (Restructured.pm, 1214)

INSTANCE METHOD. Takes a field list and turns it into a hash

Arguments:
text of field list
Returns:
hash reference

Text::Restructured::Id($self): (Restructured.pm, 1231)

INSTANCE METHOD. Returns the next identifier.

Arguments:
None

Text::Restructured::Inline($self, $parent, $text, $source, $lineno): (Restructured.pm, 1239)

INSTANCE METHOD. Parses inline markup.

Arguments:
DOM object of parent, text to parse, source, line number
Returns:
list of system_message DOMs if errors

Text::Restructured::InlineEnd($self, $text, $start, $outer_start): (Restructured.pm, 1548)

INSTANCE METHOD. Finds the matching end mark for an inline start mark. Works even if there is intervening nested markup.

Arguments:
text, start mark, start mark of outer nesting (may be null)
Returns:
boolean indicating match found, text between marks, end mark, text after end mark

Text::Restructured::InlineFindEnd($self, $text, $start, $nest_start, $null_string_ok): (Restructured.pm, 1609)

INSTANCE METHOD. Finds the first possible matching end mark for an inline start mark. Does not take into account intervening nested markup.

Arguments:
text, start mark, start mark of outer nesting (may be null)
Returns:
boolean indicating match found, text between marks, end mark, text after end mark

Text::Restructured::InlineStart($self, $text, $previous): (Restructured.pm, 1648)

INSTANCE METHOD. Finds the place where inline markup starts.

Arguments:
text, character preceding text
Returns:
Boolean indicating markup was found, characters preceding markup start, start markup string, characters after markup start

Text::Restructured::IsTable($self, $text): (Restructured.pm, 1711)

INSTANCE METHOD. Returns whether a reStructuredText string represents a valid table object.

Arguments:
string
Returns:
true or false

Text::Restructured::LineBlock($self, $para, $source, $lineno): (Restructured.pm, 1738)

INSTANCE METHOD. Processes a line block paragraph.

Arguments:
paragraph, source, line number
Returns:
processed paragraph, list of DOM objects and unprocessed paragraphs

Text::Restructured::NormalizeId($self, $s, $implicit): (Restructured.pm, 1809)

INSTANCE METHOD. Normalizes an attribute by putting it in lower case and replacing sequences of special characters with hyphens.

Arguments:
string, implicit
Returns:
normalized string

Text::Restructured::NormalizeName($self, $s, $keepcase): (Restructured.pm, 1830)

INSTANCE METHOD. Normalizes an attribute by putting it in lower case and replacing sequences of spaces with a single space.

Arguments:
string, flag to keep case
Returns:
normalized string

Text::Restructured::OptionList($self, $para, $source, $lineno): (Restructured.pm, 1857)

INSTANCE METHOD. Processes an option list paragraph.

Arguments:
paragraph, source, line number
Returns:
processed paragraph, list of DOM objects and unprocessed paragraphs

Text::Restructured::Paragraphs($self, $parent, $text, $source, $lineno): (Restructured.pm, 1906)

INSTANCE METHOD. Recursively parses a reStructuredText string that does not contain sections.

Arguments:
DOM object of parent, text to parse, source, start line number
Returns:
None, but appends parsed objects to the parent

Text::Restructured::Parse($self, $text, $filename): (Restructured.pm, 2186)

INSTANCE METHOD. Parses a reStructuredText document.

Arguments:
Text, file name
Returns:
DOM object
Uses globals:
None

Text::Restructured::QuoteSimpleTables($self, $text): (Restructured.pm, 2232)

INSTANCE METHOD. Quotes lines involved in simple tables that could be confused with section headers by starting them with a control-A (octal 001) character. Works only with properly formatted tables (ones followed by a blank line).

Arguments:
text string
Returns:
quoted text string

Text::Restructured::RegisterName($self, $dom, $source, $lineno): (Restructured.pm, 2255)

INSTANCE METHOD. Registers a target name and returns an error DOM if it is an illegal duplicate.

Arguments:
target DOM, source, line number
Returns:
optional error DOM

Text::Restructured::RemoveMinIndent($self, $para, $ifl): (Restructured.pm, 2339)

INSTANCE METHOD. Checks the lines of a paragraph for the minimum indentation and removes it.

Arguments:
paragraph string, whether to ignore the first line
Returns:
unindented paragraph string

Text::Restructured::ReregisterName($self, $olddom, $newdom): (Restructured.pm, 2353)

INSTANCE METHOD. Takes the name associated with one DOM and reassigns it to another

Arguments:
source DOM, target DOM
Returns:
None

Text::Restructured::SectionBreaks($self, $parent, $text, $source, $lineno, $section): (Restructured.pm, 2384)

INSTANCE METHOD. Parses any section breaks in the text.

Arguments:
DOM object of parent, text to parse, source, line number, first paragraph in section
Returns:
processed text, unprocessed text, new parent DOM object, list of DOM objects

Text::Restructured::SimpleTable($self, $text, $source, $lineno): (Restructured.pm, 2575)

INSTANCE METHOD. Returns a DOM object for a reStructuredText table object given a simple table text string.

Arguments:
text string, source, line number
Returns:
DOM object

Text::Restructured::Table($self, $text, $source, $lineno): (Restructured.pm, 2800)

INSTANCE METHOD. Returns a DOM object for a reStructuredText table object.

Arguments:
text string, source, line number
Returns:
DOM object

Text::Restructured::UnknownRole($self, $role, $source, $lineno, $lit, %attrs): (Restructured.pm, 2974)

INSTANCE METHOD. Returns the error messages for an unknown role name

Arguments:
role name, source, line number, optional list of attributes for last system_message
Returns:
array of DOM objects

Text::Restructured::DeepCopy($var): (Restructured.pm, 2992)

Does a "deep" copy of a data structure

Inputs:
variable
Returns:
deep copy of variable

Text::Restructured::RemoveBackslashes($str): (Restructured.pm, 3016)

Takes a string and handles backslash-quoting of characters

Arguments:
string
Returns:
processed string

Text::Restructured::Role::PEP($parser, $pep, $lit, $parent, $source, $lineno): (Restructured.pm, 3027)

Checks for validity of a PEP reference

Text::Restructured::Role::RFC($parser, $rfc, $lit, $parent, $source, $lineno): (Restructured.pm, 3043)

Checks for validity of an RFC reference

Text::Restructured::Role::raw($parser, $raw, $lit, $parent, $source, $lineno, $role): (Restructured.pm, 3059)

Checks for validity of an RAW reference

Text::Restructured::Directive::admonition($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3116)

Built-in handler for admonition directives.

Arguments:
parser, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::ascii_mathml($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3149)

Built-in handler for ascii-mathml directives.

Arguments:
parser, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::class($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3202)

Built-in handler for class directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::compound($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3233)

Built-in handler for compound directive.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::contents($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3265)

Built-in handler for contents directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::decoration($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3338)

Built-in handler for decoration directive.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::default_role($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3385)

Built-in handler for default-role directive.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::figure($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3406)

Built-in handler for figure directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::image($parser, $name, $parent, $source, $lineno, $dtext, $lit, @extra_opts): (Restructured.pm, 3488)

Built-in handler for image directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text, list of extra options allowed
Returns:
array of DOM objects

Text::Restructured::Directive::include($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3589)

Built-in handler for include directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::line_block($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3652)

Built-in handler for line-block directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::meta($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3678)

Built-in handler for meta directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::parsed_literal($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3760)

Built-in handler for parsed-literal directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::raw($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3780)

Built-in handler for raw directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::replace($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3841)

Built-in handler for replace directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::role($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3881)

Built-in handler for role directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::sectnum($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3916)

Built-in handler for sectnum directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::rubric($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3948)

Built-in handler for rubric directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::sidebar($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 3970)

Built-in handler for sidebar directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::table($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 4008)

Built-in handler for table directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::ParseCSV($parser, $string, $lines, $delim): (Restructured.pm, 4267)

Parses a comma-separated-value (CSV) table

Arguments:
parser, text string, ref to lines hash, delimiter
Returns:
reference to an array of parsed rows, each of which is a reference to an array of strings for the elements of that row OR a string error message
Side-effects:
Sets the lines hash to have as keys the row reference and as values a reference to an array containing the relative line number where each row entry starts (for giving better error messages);

Text::Restructured::Directive::ParseListTable($parser, $string, $source, $lineno): (Restructured.pm, 4293)

Parses a list table

Arguments:
parser, text string, source file, source line number
Returns:
reference to an array of parsed rows, each of which is a reference to an array of references to of array of DOM objects for the elements of that row OR a string error message

Text::Restructured::Directive::target_notes($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 4323)

Built-in handler for target-notes directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::test_directive($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 4347)

Built-in handler for test_directive directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::title($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 4377)

Built-in handler for title directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::topic($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 4394)

Built-in handler for topic directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::unicode($parser, $name, $parent, $source, $lineno, $dtext, $lit): (Restructured.pm, 4421)

Built-in handler for unicode directives.

Arguments:
parser obj, directive name, parent, source, line number, directive text, literal text
Returns:
array of DOM objects

Text::Restructured::Directive::arg_check($parser, $name, $source, $lineno, $args, $lit, $exp): (Restructured.pm, 4477)

INTERNAL ROUTINE. Returns a system error if a directive argument check fails. May also be useful to plug-in directives.

Arguments:
parser, name, source, lineno, args, lit text, expected # of args possibly appended with '+' to indicate # is min
Returns:
DOM if the check fails

Text::Restructured::Directive::bad_option($parser, $name, $opt, $val, $level, $source, $lineno, $msg, $lit): (Restructured.pm, 4495)

INTERNAL ROUTINE. Returns a system message specifying a bad option. May also be useful to plug-in directives.

Arguments:
parser, directive name, option name, option value, level, source, line number, message, optional literal block
Returns:
system_message DOM

Text::Restructured::Directive::check_enum_option($parser, $name, $opt, $val, $vallist, $source, $lineno, $lit): (Restructured.pm, 4513)

INTERNAL ROUTINE. Returns a system message DOM if the option value does not parse as one of an enumerated list. May also be useful to plug-in directives.

Arguments:
parser, directive name, option name, option value, ref to array of enum names, source, line number, literal
Returns:
error DOM or None

Text::Restructured::Directive::check_fieldlist_option($parser, $name, $opt, $val, $option, $source, $lineno, $lit): (Restructured.pm, 4537)

INTERNAL ROUTINE. Returns a system message DOM if the option value does not parse as a field list. May also be useful to plug-in directives.

Arguments:
parser, directive name, option name, option value, complete option string, source, line number, literal
Returns:
error DOM or None

Text::Restructured::Directive::check_int_option($parser, $name, $opt, $val, $option, $source, $lineno, $lit, $pos): (Restructured.pm, 4552)

INTERNAL ROUTINE. Returns a system message DOM if the option value does not parse as integer. May also be useful to plug-in directives.

Arguments:
parser, directive name, option name, option value, complete option string, source, line number, literal, optional argument indicating minimum OK value (0 or 1)
Returns:
error DOM or None

Text::Restructured::Directive::check_option_names($parser, $name, $options, $optlist, $source, $lineno, $lit): (Restructured.pm, 4576)

INTERNAL ROUTINE. Returns a system message DOM if any of the options in the option hash are not in the legal option list array. May also be useful to plug-in directives.

Arguments:
parser, directive name, reference to option hash, reference to array of legal option names, source, line number, literal

Text::Restructured::Directive::check_required_option($parser, $name, $opt, $val, $source, $lineno, $lit): (Restructured.pm, 4601)

INTERNAL ROUTINE. Returns a system message DOM if the option value is empty. May also be useful to plug-in directives.

Arguments:
parser, directive name, option name, option value, source, line number, literal
Returns:
error DOM or none

Text::Restructured::Directive::check_units_option($parser, $name, $opt, $val, $source, $lineno, $lit, @extra_units): (Restructured.pm, 4618)

INTERNAL ROUTINE. Returns a system message DOM if the option value does not parse as a positive measure of a defined unit. May also be useful to plug-in directives.

Arguments:
parser, directive name, option name, option value, source, line number, literal, list of extra units
Returns:
error DOM or none
Uses globals:
@Text::Restructured::UNITS
Causes side-effects:
option value has whitespace removed if valid

Text::Restructured::Directive::handle_directive($name, $sub): (Restructured.pm, 4638)

Adds a handler for a directive. Used by plug-in directives to register a routine to call for a given directive name.

Arguments:
directive name, reference to directive subroutine

Text::Restructured::Directive::parse_directive($parser, $dtext, $lit, $source, $lineno, $opts_p, $req_arg): (Restructured.pm, 4651)

INTERNAL ROUTINE. Parses the text of a directive into its arguments, options, and contents. May also be useful to plug-in directives.

Arguments:
Parser obj, Directive text, literal text, source, lineno, reference to array of allowed options (optional) required # of arguments appended with '+' if minimum (optional),
Returns:
Error DOM or directive arguments hash ref

Text::Restructured::Directive::system_error(): (Restructured.pm, 4732)

INTERNAL ROUTINE. Returns a canonically formatted version of the last system error.

Arguments:
None
Returns:
error string

Text::Restructured::Directive::system_msg($parser, $name, $level, $source, $lineno, $msg, $lit, %attr): (Restructured.pm, 4742)

INTERNAL ROUTINE. Returns a DOM object for a system message, with 'Error in "name" directive" prepended to the message. May also be useful to plug-in directives.

Arguments:
parser obj, directive name, level, source, lineno, message, literal string, attribute pairs

DOM.pm

Text::Restructured::DOM::new($class, $tag, %attr): (DOM.pm, 40)

CLASS METHOD. Creates a new DOM object.

Arguments:
(optional) tag, (optional) list of attribute/value pairs
Returns:
DOM object

Text::Restructured::DOM::newPCDATA($class, $text): (DOM.pm, 54)

CLASS METHOD. Creates a new DOM object that is a "#PCDATA" type.

Arguments:
text
Returns:
DOM object

Text::Restructured::DOM::append($dom, @doms): (DOM.pm, 64)

INSTANCE METHOD. INSTANCE METHOD. Appends to the contents of a DOM object.

Arguments:
DOM objects to append
Returns:
The new number of contents

Text::Restructured::DOM::child($dom, $n): (DOM.pm, 75)

INSTANCE METHOD. INSTANCE METHOD. Returns the child with index n in the contents (0-based)

Arguments:
n
Returns:
child DOM object or undef

Text::Restructured::DOM::contents($dom): (DOM.pm, 84)

INSTANCE METHOD. INSTANCE METHOD. Returns the content objects the DOM object has

Arguments:
None
Returns:
Array of content DOM objects

Text::Restructured::DOM::first($dom): (DOM.pm, 94)

INSTANCE METHOD. INSTANCE METHOD. Returns the first DOM in the contents of a DOM.

Arguments:
None
Returns:
first DOM object (or undefined)

Text::Restructured::DOM::index($dom, $child): (DOM.pm, 108)

INSTANCE METHOD. INSTANCE METHOD. Returns the index of a child in the contents (-1 if it does not occur).

Arguments:
child DOM object
Returns:
index number

Text::Restructured::DOM::last($dom): (DOM.pm, 121)

INSTANCE METHOD. INSTANCE METHOD. Returns the last DOM in the contents of a DOM.

Arguments:
None
Returns:
last DOM object (or undefined)

Text::Restructured::DOM::next($dom, $ignore): (DOM.pm, 137)

INSTANCE METHOD. INSTANCE METHOD. Returns the next DOM in the logical structure of the tree. If the given DOM is the last in a section or list, this routine may have to go up in the tree to find the next object.

Arguments:
optional regular expression for tags to ignore
Returns:
next DOM or undef

Text::Restructured::DOM::num_contents($dom, @doms): (DOM.pm, 164)

INSTANCE METHOD. INSTANCE METHOD. Returns the number of content objects the DOM object has

Arguments:
None
Returns:
Number of elements

Text::Restructured::DOM::parent($dom): (DOM.pm, 174)

INSTANCE METHOD. INSTANCE METHOD. Returns the parent DOM of an instance.

Arguments:
None
Returns:
The DOM object's parent

Text::Restructured::DOM::prepend($dom, @doms): (DOM.pm, 184)

INSTANCE METHOD. INSTANCE METHOD. Puts the arguments at the beginning of the contents of a DOM object.

Arguments:
DOM objects to prepend
Returns:
The new number of objects

Text::Restructured::DOM::Recurse($dom, $sub, $when, @args): (DOM.pm, 202)

INSTANCE METHOD. INSTANCE METHOD. Goes through a DOM object recursively calling a subroutine on every element. It can do either preorder, postorder or bothorder traversal (defaults to postorder). Unlike Reshape, it does not modify the children of the nodes it visits.

Arguments:
callback routine, optional 'pre'/'post'/'both', optional additional arguments to be propagated
Returns:
Stop recursion flag
Callback routine arguments:
target DOM, 'pre'/'post', optional additional arguments
Callback routine returns:
non-zero in 'pre' mode to avoid further recursion.

Text::Restructured::DOM::replace($dom, @doms): (DOM.pm, 230)

INSTANCE METHOD. INSTANCE METHOD. Replaces the contents of a DOM object with a new set of objects.

Arguments:
DOM objects to replace
Returns:
None

Text::Restructured::DOM::Reshape($dom, $sub, $when, @args): (DOM.pm, 251)

INSTANCE METHOD. INSTANCE METHOD. Goes through a DOM object recursively calling a subroutine on every element. It can do either preorder, postorder or bothorder traversal (defaults to postorder).

Arguments:
callback routine, optional 'pre'/'post'/'both', optional additional arguments to be propagated
Returns:
Reference to new set objects to replace the current object
Callback routine arguments:
target DOM, 'pre'/'post', optional additional arguments
Callback routine returns:
whatever list of DOM objects are to be substituted for the current node (this list is returned on the 'post' call if 'both' is selected).

Text::Restructured::DOM::splice($dom, $index, $n, @doms): (DOM.pm, 284)

INSTANCE METHOD. INSTANCE METHOD. Splices objects into the contents of a DOM object.

Arguments:
start index, number to replace, list of DOM objects to splice
Returns:
Array of removed objects

Text::Restructured::DOM::substitute($dom, @new_doms): (DOM.pm, 296)

INSTANCE METHOD. INSTANCE METHOD. Substitutes a different set of DOM objects for a given DOM object in the contents of its parent.

Arguments:
list of DOM objects
Returns:
None

Text::Restructured::DOM::tag($dom, $new_tag): (DOM.pm, 312)

INSTANCE METHOD. INSTANCE METHOD. Returns the tag of a DOM object

Arguments:
Optional new tag value
Returns:
Tag

Text::Restructured::DOM::Parse($text, $opt): (DOM.pm, 323)

Parses text that is in DOM (pseudo-XML) format.

Arguments:
Text, reference to hash of command-line options
Returns:
DOM object
Uses globals:
None

Text::Restructured::DOM::takes_body_elts($dom): (DOM.pm, 430)

INSTANCE METHOD. INSTANCE METHOD.

Arguments:
None
Returns:
True if the DOM object can take body elements in its contents

Text::Restructured::DOM::takes_inline_elts($dom): (DOM.pm, 438)

INSTANCE METHOD. INSTANCE METHOD.

Arguments:
None
Returns:
True if the DOM object can take inline elements in its contents

Text::Restructured::DOM::is_body_elt($dom): (DOM.pm, 446)

INSTANCE METHOD. INSTANCE METHOD.

Arguments:
None
Returns:
True if the DOM object is a body element

Text::Restructured::DOM::is_inline_elt($dom): (DOM.pm, 454)

INSTANCE METHOD. INSTANCE METHOD.

Arguments:
None
Returns:
True if the DOM object is an inline element

Graph.pm

Text::Restructured::Graph::new(): (Graph.pm, 32)

CLASS METHOD. Creates a new graph object.

Returns:
reference to a graph object

Text::Restructured::Graph::AddEdge($g, $p1, $p2): (Graph.pm, 40)

INSTANCE METHOD. Adds an edge to the graph.

Arguments:
point object 1, point object 2
Returns:
None

Text::Restructured::Graph::SetVertexProp($g, $p, $prop, $val): (Graph.pm, 51)

INSTANCE METHOD. Sets a user-defined property for a vertex.

Arguments:
point object, property name, property value
Returns:
None

Text::Restructured::Graph::GetVertexProp($g, $p, $prop): (Graph.pm, 61)

INSTANCE METHOD. Gets a user-defined property for a vertex.

Arguments:
point object, property name
Returns:
Property value

Text::Restructured::Graph::GetVertices($g): (Graph.pm, 71)

INSTANCE METHOD. Gets the list of vertices in the graph.

Arguments:
None
Returns:
array of point objects

Text::Restructured::Graph::GetVertexEdges($g, $p): (Graph.pm, 88)

INSTANCE METHOD. Gets a list of vertices adjacent to a vertex.

Arguments:
point object
Returns:
array of point objects

Text::Restructured::Graph::DFS($g, $p, $sub): (Graph.pm, 100)

INSTANCE METHOD. Does a Depth-First Search of a graph from a given starting point.

Arguments:
point object, callback routine
Returns:
None
Callback routine arguments:
graph, point
Callback routine returns:
None

Text::Restructured::Graph::_DFS($g, $p, $sub): (Graph.pm, 111)

Internal routine. Called recursively by DFS.

Transforms.pm

Text::Restructured::docutils::transforms::components::Filter($dom, $parser, $details): (Transforms.pm, 81)

Processes a docutils.transforms.components.Filter transform.

Arguments:
pending DOM, parser obj, details hash reference

Text::Restructured::docutils::transforms::frontmatter::process_docinfo($dom, $parser): (Transforms.pm, 107)

Text::Restructured::docutils::transforms::frontmatter::DocInfo($dom, $parser, $level): (Transforms.pm, 274)

Processes a docutils.transforms.frontmatter.DocInfo transform. Processes field lists at the beginning of the DOM that are one of the docinfo types into a docinfo section.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::frontmatter::DocTitle($dom, $parser): (Transforms.pm, 292)

Processes a docutils.transforms.frontmatter.DocTitle transform. Creates a document title if the top-level DOM has only one top-level section. Creates a subtitle if a unique top-level section has a unique second-level section.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::frontmatter::SectionSubTitle($topdom, $parser): (Transforms.pm, 305)

Processes a docutils.transforms.frontmatter.SectionSubTitle transform. Creates a subtitle if a section DOM has only one top-level subsection.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::frontmatter::create_title($dom, $parser): (Transforms.pm, 324)

Used to turn a lone section into a title/subtitle of the given DOM

Arguments:
section DOM object
Returns:
None
Side-effects:
May reorganize the contents to promote a lone section

Text::Restructured::docutils::transforms::misc::Pending($topdom, $parser): (Transforms.pm, 400)

Processes a docutils.transforms.misc.Pending transform. Traverses the DOM tree looking for Pending nodes and applies whatever internal transform was specified for them.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::parts::Class($dom, $parser, $details): (Transforms.pm, 452)

Processes a docutils.transforms.parts.Class transform.

Arguments:
pending DOM, parser obj, details hash reference

Text::Restructured::docutils::transforms::parts::Contents($dom, $parser, $details): (Transforms.pm, 469)

Processes a docutils.transforms.parts.Contents transform.

Arguments:
pending DOM, parser obj, details hash reference

Text::Restructured::docutils::transforms::parts::Sectnum($dom, $parser, $details): (Transforms.pm, 569)

Processes a docutils.transforms.parts.Sectnum transform. Auto-numbers the sections in the document.

Arguments:
pending DOM, parser obj, details hash reference

Text::Restructured::docutils::transforms::references::AutoFootnotes($dom, $parser): (Transforms.pm, 641)

Processes a docutils.transforms.references.AutoFootnotes transform. Computes numbers for autonumbered footnotes.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::references::IndTargets($dom, $parser): (Transforms.pm, 693)

Processes a docutils.transforms.references.IndTargets transform. Links indirect targets and bare targets to their eventual destination.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::references::CitationReferences($dom, $parser): (Transforms.pm, 880)

Processes a docutils.transforms.references.CitationReferences transform. Links citation references to their targets.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::references::FootnoteReferences($dom, $parser): (Transforms.pm, 944)

Processes a docutils.transforms.references.FootnoteReferences transform. Links footnote references to their targets.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::references::MarkReferenced($dom, $parser): (Transforms.pm, 997)

Processes a docutils.transforms.references.MarkReferenced transform. Marks immediate destinations of references as referenced.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::references::References($dom, $parser): (Transforms.pm, 1025)

Processes a docutils.transforms.references.References transform. Counts anonymous references, links references to their destinations, produces error messages if the number of anonymous references is insufficient.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::references::Unreferenced($dom, $parser): (Transforms.pm, 1155)

Processes a docutils.transforms.references.Unreferenced transform. Produces messages for unreferenced targets.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::references::TargetNotes($dom, $parser, $details): (Transforms.pm, 1187)

Processes a docutils.transforms.references.TargetNotes transform. Constructs a list of external references and creates footnotes pointing to them.

Arguments:
pending DOM, parser obj, details hash reference

Text::Restructured::docutils::transforms::universal::Decorations($topdom, $parser): (Transforms.pm, 1255)

Processes a docutils.transforms.universal.Decorations transform. Adds the "View document source", "Generated on" and "Generated by" decorations to the end of the document.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::universal::EmptyTopics($dom, $parser): (Transforms.pm, 1324)

Processes a docutils.transforms.universal.EmptyTopics transform. Removes any topics that have only a header in their contents.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::universal::Messages($dom, $parser): (Transforms.pm, 1340)

Processes a docutils.transforms.universal.Messages transform. Moves system messages at the end into "Docutils System Messages" section.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::universal::ScoopMessages($dom, $parser): (Transforms.pm, 1369)

Processes a docutils.transforms.universal.ScoopMessages transform. Moves system messages from anywhere in the DOM tree to the end of the top-level DOM.

Arguments:
top-level DOM, parser obj

Text::Restructured::docutils::transforms::universal::Transitions($dom, $parser): (Transforms.pm, 1392)

Processes a docutils.transforms.universal.Transitions transform. Moves transitions at end of sections to top level and creates error messages for incorrect transitions.

Arguments:
top-level DOM, parser obj

Writer.pm

Text::Restructured::Writer::new($class, $writer_name, $opt): (Writer.pm, 32)

CLASS METHOD. Creates a new Writer object.

Arguments:
writer name, reference to hash of command-line options
Returns:
Writer object

Text::Restructured::Writer::Ancestors($self): (Writer.pm, 60)

INSTANCE METHOD. Returns a reference to the array of ancestors in the traversal. The last one is the immediate parent.

Arguments:
none
Returns:
Array reference

Text::Restructured::Writer::ParseSchema($self, $writer): (Writer.pm, 69)

INSTANCE METHOD. Parses the writer's schema file.

Arguments:
file name
Returns:
None
Modifies instance variables:
phases, handler

Text::Restructured::Writer::Precompile($self): (Writer.pm, 131)

INSTANCE METHOD. Precompiles the writer's subroutines

Arguments:
None
Returns:
None
Modifies instance variables:
handler

Text::Restructured::Writer::ProcessDOM($self, $dom): (Writer.pm, 152)

INSTANCE METHOD. Passes the DOM through all phases of the writer and returns the output string.

Arguments:
parsed DOM
Returns:
string

Text::Restructured::Writer::ProcessDOMPhase($self, $dom, $phase): (Writer.pm, 165)

INSTANCE METHOD. Passes the DOM through a specific phase of the writer and returns the output string. Uses the current phase if no phase is specified.

Arguments:
parsed DOM, phase name
Returns:
string returned from processing the phase

Text::Restructured::Writer::TraverseDOM($self, $dom, $phase, $handarray, $searchstring): (Writer.pm, 177)

INSTANCE METHOD. Internal routine called by TraverseDOM to do recursive handling of DOM tree.

Arguments:
parsed DOM, handler array reference, search string

Text::Restructured::Writer::DoEval($self, $str, $line, $subname): (Writer.pm, 215)

INSTANCE METHOD. INSTANCE METHOD Precompiles a subroutine that evaluates an expression.

Arguments:
string expression, line number, optional subroutine name
Returns:
anonymous subroutine reference
Exceptions:
Program termination if error in evaluation
Uses globals:
None
Sets globals:
Text::Restructured::Writer::Eval::<subname>

Data structures

These are the principal data structures in prest as compiled from the Perl sources.

Handler:

Hash reference with the following keys:

tag:
Regular expression for tag matching
line:
Line number where function is defined
text:
Textual representation of the code to run on tag match
code:

Code reference for the code to run on tag match. The code is a subroutine with two arguments:

the matching DOM object

the string returned recursively from the content of this DOM.

It needs to return a string. Any string returned by the top level is printed to STDOUT.

Handler array:
Reference to array of handler objects.
Text::Restructured:

reStructuredText parser hash reference with the following keys:

next_id:
The next id to be returned by Id() method;
SEC_LEVEL:
Hash reference whose keys are header styles and whose value (if defined) indicates the level of sections encoded with that header style.
SEC_DOM:
Array reference whose index is the section level and whose value is the section DOM object at that level.
SEC_STYLE:
Array reference whose index is the section level and whose value is the section style at that level.
ANONYMOUS_TARGETS:
Array reference of references to anonymous target DOMs in file order.
REFERENCE_DOM:
Hash reference whose keys are tags and whose values are references to a hash with names or ids as keys and the associated target DOM object as value.
TARGET_NAME:
Hash reference whose keys are namespace ids and whose values are references to a hash whose keys are names and whose value is a reference to an array of all the DOM objects having that name in that name space.
ALL_TARGET_IDS:
Hash reference whose keys are ids and whose value is a reference to an array of all the DOM objects having that id.
ALL_TARGET_NAMES:
Hash reference whose keys are names and whose value is a reference to an array of all the DOM objects having that name.
MY_ROLES:
Hash reference whose keys are the role names that are currently defined for the current document (it gets reset between documents) and whose values are Role definition hash references.
MY_DEFAULT_ROLE:
The current name of the default role for the current document. Initially title_reference.
Directive arguments hash ref:

Returned by Text::Restructured::Directive::parse_directive. It has keys:

name:
the directive name
args:
parsed arguments from dtext
options:
reference to hash of parsed option/value pairs
content:
parsed content from dtext
content_lineno:
line number of the content block
Role definition hash reference:

Used for a role definition. It has keys (all are optional except tag):

tag:
the tag used for a DOM object using the role (required)
attr:
reference to hash whose keys are attribute names and whose values are sprintf strings that are called with interpreted text
text:
sprintf string called with the interpreted text to produce the final text string
alias:
name of another role for which this is a synonym
check:
reference to subroutine to call to check validity of the interpreted text. The arguments to the routine are (interpreted text, literal of interpreted/role combination, DOM object for future parent, source file name, line number).
Text::Restructured::DOM:

Recursive hash reference with following keys:

tag:
The name of the tag of the DOM object
attr:
Reference to hash of attribute/value pairs
content:
Reference to array of DOM objects
text:
Contains the literal text for #PCDATA
internal:
Reference to hash of internal attribute/value pairs
source:
Optionally contains the source
lineno:
Optionally contains the line number
lit:
Optionally contains the literal text
val:
The value returned by the DOM's handler (added during traversal of the writer's handlers)
Graph object:

A hash reference. The hash is accessed through two levels of indices representing the x-coordinate and the y-coordinate of a vertex in the graph. The next level of indexing is a hash reference with special keys

edges:
an array of point objects that are incident to the vertex
props:
a hash of user-defined properties on the vertex
Point object:
A reference to an array with two elements giving the x and y coordinates of the point.
Text::Restructured::Writer:

Hash reference with following keys:

handler:
Reference to hash whose keys are phase names and whose values are handler structures.
phases:
Reference to array of phase names (in order)
ancestors:
Reference to array of ancestor DOMs during traversal
handler:

Hash reference with the following keys

tag:
Regular expression of DOM tags handled by the handler
line:
The file and line number where the handler routine was defined
text:
Text of the subroutine's definition
code:
Subroutine reference implementing text

Global variables

These are the global variables used in prest as compiled from the Perl sources.

$main::TOP_FILE:
Name of the top-level file being processed.
$main::MY_DIR:
The real directory in which the prest script lives
$main::TOOL_ID:
The tool name and release number
$main::VERSION:
The prest version

Many static (read-only) variables defined in BEGIN blocks (not documented).

%DOM::PARENT:
hash whose keys are DOM references and whose values are a reference to the DOM object of the parent. Should only be accessed indirectly through the DOM::parent method.
@Transforms::TRANSFORMS
Array of transform names in the order they will be applied.