TextBlock

Represents a block of text with a particular style.

These are the standard types of text blocks:

doc

Document type. A structural type which can contain other structural types.

para

Paragragh type. A structural type which can not contain other structural types.

unorderedList

Unordered list. A structural type in which each of the words are of type doc.

definitionList

Definition list. A structural type in which each of the words are of type definitionItem.

definitionItem

An item in a definition list. A structural type that always contains exactly two words: a text item and a doc item.

text

A block of text that can contain only non-structural types.

underline

Underlined text.

bold

Boldfaced text.

italic

Italic text.

ref

Reference to a text location. In this case, the first word is a reference, the remainder is the anchor text.

img

The first word of the text is the name of an image file. The remainder of the text is ignored.

exec

Executes its contents as a shell command. In the event of an error, raises a parsing error. Output from the command is treated as NML source which is parsed in context.

n

Force a newline at this point in the enclosing text. All of the words are ignored.

X

The enclosed text is a cross reference (XXX this is very weak at this time - only can be used to reference other parts of the same document).

C

The enclosed text is a comment, and should not be visible when the document is rendered.

There are a variety of special types of text blocks:

literal

backquoted type - everything in it is literal except the backslash.

prelit

preformatted/literal type. Everything in it is literal and the raw format (extraneous whitespace) of the original should be preserved. This type only has one word.

pre

Preformatted. Raw format of the original should be preserved.

Methods

__init__(self, src, typeName, tightLeft)

   def __init__(self, src, typeName, tightLeft = 0):

Constructs a text block.

src

either a tuple (filename, line number) or a LineReader. Any other type is ignored.

typeName

Type name of the block.

tightLeft

If specified, indicates whether the block binds tightly (without whitespace) to the information to the left of it.

__str__(self)

   def __str__(self):

Returns the block in a minimal string format - basically this is raw content with spaces between words.

addChild(self, child)

   def addChild(self, child):

Adds a child text block to the receiver.

addWords(self, words)

   def addWords(self, words):

adds the given sequence of words to the receiver.

consume(self, str)

   def consume(self, str):

Consumes a string in a manner appropriate to the text block.

debug(self, soFar)

   def debug(self, soFar = ''):

Prints self in a form useful to der programmer. Returns the last line as a string.