types1668%python.module
fault.text

Text data structures for working with paragraph content.

Fragment and Paragraph are designed to be easily transformed and serialized using common tools. Fragment should always be a pair-tuple, and Paragraph a sequence of Fragments. The JSON/msgpack representation would likely be a sequence of sequences or a pair of sequences to be recombined.

These text structure primitives are not ideal for managing fine grained formatting control. They are intended for managing semantic markup. However, Fragment being arbitrarily typed allows for format control events that could be interpreted by a Processing Context for such a purpose.

Sequence
import

Iterable
import

Mapping
import

ElementTree0
data

ElementTree = tuple[str, Sequence['ElementTree'], Mapping]

Fragment0
class

An explicitly typed portion of text used as part of a Paragraph.

Fragment__slots__0
data

__slots__ = ()
	@property

Fragmenttypepath0
property
Sequence[str]

Fragmentdata150%
property
str

Fragmentemphasis420%
property
int

Return the integer weight of the emphasized text. None if the text is not emphasized.

Fragmenttype233%
property
str

Type string of the fragment.

Usually a / separated string where the first two fields are supposed to exist unconditionally. Common prefixes:

  • text/normal

  • text/emphasis/[0-9]*

  • reference/hyperlink

  • referance/section

  • reference/ambiguous

  • reference/parenthetical

  • literal/grave-accent

Fragmentroot233%
property
str

Initial path entry. Usually reference, literal, or text.

Fragmentnew20%
classmethod

new(Class, type, data)

Create a new instance with an explicitly declared type.

Paragraph0
class

A sequence of Fragment instances forming a paragraph.

Paragraph__slots__0
data

__slots__ = ()

Paragraph__repr__150%
method
str

__repr__(self)

Paragraphof0
classmethod

of(Class, *sequence)

Variable argument based Paragraph constructor.

Paragraphsole0
property
Fragment

Return the first and only fragment of the Paragraph. If multiple fragments exist, a ValueError is raised.

Paragraphsentences477%
property
Iterable[Sequence[Fragment]]

Iterator producing lists that contain the sentence contents. A sentence in a paragraph is delimited by . contained within 'text'