render13812%python.module
fault.text

Format text elements into text images.

Paragraph level formatting functions usually return Fragment while section-level returns Image.

chapter and elements are the primary entry points where chapter takes a single chapter element and elements takes a sequence of arbitrary elements.

Types

Fragment

A string without newlines.

Line

A sequence of Fragment instances.

Image

An iterator producing Line instances.

Sequence
import

Iterable
import

types0
import

document0
import

Fragment0
data

Fragment = str

Line0
data

Line = Sequence[Fragment]

Image0
data

Image = Iterable[Line]

syntax811%
function
Image

syntax(lines, syntype, qualifier, adjustment)

Generator producing sequences of line text for a syntax element.

syntaxParameters

lines
  • Iterable[str]

Iterator of syntax lines without newlines.

syntype

The syntax type of lines.

qualifier

The suffix of the syntax command line.

adjustment

Indentation level adjustment.

section_path118%
function
Line

section_path(rdepth, rmultiple, *path)

Construct a section selector from a relative depth and a section identifier path.

ambiguous_reference233%
function
Fragment

ambiguous_reference(string)

Prefix the given string with an ampersand.

section_reference233%
function
Fragment

section_reference(section_selector)

Prefix the given string with an ampersand after enclosing it with brackets.

literal233%
function
Fragment

literal(string)

Surround the string with grave-accents and replace any grave-accent within with two.

_p_fragments0
data

_p_fragments = {
	('reference', 'ambiguous'): ambiguous_reference,
	('reference', 'hyperlink'): hyperlink,
	('reference', 'section'): section_reference,
	('literal', 'grave-accent'): literal,
	('text', 'normal'): (lambda x: x),
	('text', 'line-break'): (lambda x: " "),
	('text', 'emphasis'): (lambda x: x),
}

paragraph195%
function
Image

paragraph(para)

Generator producing an Image representing the given fault.text.types.Paragraph.

inline_fragment150%
function
Fragment

inline_fragment(frag)

_chapter30%
function

_chapter(depth, element)

_section80%
function

_section(depth, element)

_syn80%
function

_syn(depth, syntax)

_para80%
function

_para(depth, element)

_list160%
function

_list(depth, element, list_type)

_sequence10%
function

_sequence(depth, element)

_set10%
function

_set(depth, element)

_directory220%
function

_directory(depth, element)

_admonition60%
function

_admonition(depth, element)

_index0
data

_index = {
	'section': _section,
	'chapter': _chapter,
	'paragraph': _para,
	'syntax': _syn,
	'admonition': _admonition,

	'set': _set,
	'sequence': _sequence,
	'dictionary': _directory,
	'directory': _directory,

	# No-op element type often providing additional metadata.
	'void': (lambda x, y: ()),
}

_tree30%
function

_tree(depth, elements)

tree516%
function
Image

tree(element, adjustment, indentation, newline)

Produce the image representing the given element including newline characters.

treeParameters

element

Any document element.

adjustment

The indentation difference to render Lines with. Zero by default.

indentation

The indentation character or sequence to render lines with.

newline

The character or sequence to append to each line in the image. May be an empty string to supress line terminators.

elements516%
function
Image

elements(elements, adjustment, indentation, newline)

Produce the image representing the given elements sequence.

elementsParameters

elements

Sequence of arbitrary text elements.

adjustment

The indentation difference to render Lines with. Zero by default.

indentation

The indentation character or sequence to render lines with.

newline

The character or sequence to append to each line in the image. May be an empty string to supress line terminators.

chapter516%
function
Image

chapter(element, adjustment, indentation, newline)

Produce the image representing the given chapter element including newline characters.

chapterParameters

element

Any document element.

adjustment

The indentation difference to render Lines with. Zero by default.

indentation

The indentation character or sequence to render lines with.

newline

The character or sequence to append to each line in the image. May be an empty string to supress line terminators.