NAME

oEdtk::Doc - abstract base class for emitted documents

SYNOPSIS

use oEdtk::Doc;        # usually used through a subclass, e.g. oEdtk::TexDoc

my $doc = oEdtk::TexDoc->new;
$doc->append('NOM', 'value');
print $doc;            # dump(), through the "" overload

DESCRIPTION

The base class for a document built as an ordered list of tags. It stores the tags, dumps them as a string, inserting a line break once the running length exceeds the line cutoff, and stringifies to dump through the "" overload. The tag factory and the escaping rules are provided by subclasses (oEdtk::TexDoc).

METHODS

new

my $doc = oEdtk::Doc->new;

Create an empty document.

reset

$doc->reset;

Clear the tag list and the emitted-length counter, and return the object.

append

$doc->append($name, $value);

Append a tag. $name may be an oEdtk::Doc (its tags are appended), a hash reference (each key is appended in turn), or a tag name paired with $value (built through "mktag"). Returns the object.

dump

my $out = $doc->dump;

Concatenate the emitted tags, inserting "line_break" whenever the running length would cross the line cutoff (default 120, overridable with the EDTK_LINE_CUTOFF key of the COMPO section). This is also the "" overload.

include

$doc->include($file, $path);

Append an _include_ tag for $file under $path. A $path naming an EDTK_DIR_* key is resolved through the ENVDESC section; a missing file is an error. Returns the object.

mktag

Abstract: build the tag object for $name and $value. Unimplemented here (it dies); a concrete subclass such as oEdtk::TexDoc provides it.

append_table

Abstract: append a table under $name. Unimplemented here (it dies).

line_break

Abstract: return the string inserted at a line break. Unimplemented here (it dies).

escape

Abstract: escape a string for the target format. Unimplemented here (it dies).

The private helper _line_cutoff resolves and caches the effective line cutoff; it is not part of the public API.

AUTHOR

The oEdtk team.