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
Iterable
Mapping
ElementTree0
ElementTree = tuple[str, Sequence['ElementTree'], Mapping]
Fragment0
An explicitly typed portion of text used as part of a Paragraph.
Fragment__slots__0
__slots__ = ()
@property
Fragmenttypepath0Sequence[str]
Fragmentdata150%str
Fragmentemphasis420%int
Return the integer weight of the emphasized text. None if the text is not emphasized.
Fragmenttype233%str
Type string of the fragment.
Usually a / separated string where the first two fields are supposed to exist unconditionally. Common prefixes:
text/normaltext/emphasis/[0-9]*reference/hyperlinkreferance/sectionreference/ambiguousreference/parentheticalliteral/grave-accent
Fragmentroot233%str
Initial path entry. Usually reference, literal, or text.
Fragmentnew20%
new(Class, type, data)
Create a new instance with an explicitly declared type.
Paragraph0
A sequence of Fragment instances forming a paragraph.
Paragraph__slots__0
__slots__ = ()
Paragraph__repr__150%str
__repr__(self)
Paragraphof0
of(Class, *sequence)
Variable argument based Paragraph constructor.
Paragraphsole0Fragment
Return the first and only fragment of the Paragraph. If multiple fragments exist, a ValueError is raised.
Paragraphsentences477%Iterable[Sequence[Fragment]]
Iterator producing lists that contain the sentence contents. A sentence in a paragraph is delimited by . contained within 'text'