lpod.paragraph

class lpod.paragraph.odf_paragraph(native_element, cache=None)

Bases: lpod.element.odf_element

Specialised element for paragraphs.

append_plain_text(text=u'', encoding=None)

Append unicode plain text to the paragraph, replacing <CR>, <TAB> and multiple spaces by ODF corresponding tags.

get_formatted_text(context)
get_style()
get_text_style()
insert_annotation(annotation_element=None, after=None, body=None, creator=None, date=None)
insert_note(note_element=None, after=None, note_class='footnote', note_id=None, citation=None, body=None, *args, **kw)
insert_variable(variable_element, after)
set_bookmark(name, before=None, after=None, position=0, role=None, content=None)

Insert a bookmark before or after the characters in the text which match the regex before/after. When the regex matches more of one part of the text, position can be set to choose which part must be used. If before and after are None, we use only position that is the number of characters. So, by default, this function inserts a bookmark before the first character of the content. Role can be None, “start” or “end”, we insert respectively a position bookmark a bookmark-start or a bookmark-end. If content is not None these 2 calls are equivalent:

paragraph.set_bookmark("bookmark", content="xyz")

and:

paragraph.set_bookmark("bookmark", before="xyz", role="start")
paragraph.set_bookmark("bookmark", after="xyz", role="end")

If position is a 2-tuple, these 2 calls are equivalent:

paragraph.set_bookmark("bookmark", position=(10, 20))

and:

paragraph.set_bookmark("bookmark", position=10, role="start")
paragraph.set_bookmark("bookmark", position=20, role="end")

Arguments:

name – str

before – unicode regex

after – unicode regex

position – int or (int, int)

role – None, “start” or “end”

content – unicode regex

Make a link from text content matching the regex OR the positional arguments.

set_span(style, regex=None, offset=None, length=0)

Apply the given style to text content matching the regex OR the positional arguments offset and length.

Arguments:

style – style element or name

regex – unicode regular expression

offset – int

length – int

set_style(name)
set_text_style(name)
class lpod.paragraph.odf_span(native_element, cache=None)

Bases: lpod.paragraph.odf_paragraph

lpod.paragraph.odf_create_line_break()

This element represents a line break.

Return odf_element

lpod.paragraph.odf_create_paragraph(text_or_element=None, style=None)

Create a paragraph element of the given style containing the optional given text.

Arguments:

text – unicode or odf_element

style – unicode

Return: odf_element

lpod.paragraph.odf_create_spaces(number=1)

This element shall be used to represent the second and all following “ “ (U+0020, SPACE) characters in a sequence of “ “ (U+0020, SPACE) characters. Note: It is not an error if the character preceding the element is not a white space character, but it is good practice to use this element only for the second and all following SPACE characters in a sequence.

Arguments:

number – int

Return odf_element

lpod.paragraph.odf_create_tabulation(position=None)

This element represents the [UNICODE] tab character (HORIZONTAL TABULATION, U+0009).

The position attribute contains the number of the tab-stop to which a tab character refers. The position 0 marks the start margin of a paragraph. Note: The position attribute is only a hint to help non-layout oriented consumers to determine the tab/tab-stop association. Layout oriented consumers should determine the tab positions based on the style information

Arguments:

number – int

Return odf_element

Previous topic

lpod.note

Next topic

lpod.reference

This Page