Next / Previous / Contents / Shipman's homepage

20. class Paragraph: General container for a paragraph of narrative

An instance of this class is a container for mixed content as defined in Section 5.15, “The narrative elements”. The constructor takes this form, and returns a new, empty instance:

Paragraph()

20.1. Paragraph.addContent(): Add content

To add content to a Paragraph instance P, use this method:

P.addContent(tag, text)
tag

To add ordinary text to the paragraph, pass None as this argument. To add text marked up with one of the element names in the para-markup pattern of the schema, pass the element name as this argument.

text

A string containing the text to be added.

Here is an example. Suppose you want to represent this text:

Read about Tyrannus couchii in NMOS Journal next month.

This code sequence would build a Paragraph instance p with that content:

p = Paragraph()
p.addContent ( None, 'Read about ' )
p.addContent ( 'genus', 'Tyrannus couchii' )
p.addContent ( None, ' in ' )
p.addContent ( 'cite', 'NMOS Journal' )
p.addContent ( None, ' next month.' )