Bases: lpod.paragraph_base.paragraph_base
Specialised element for paragraphs <text:p>. The <text:p> element represents a paragraph, which is the basic unit of text in an OpenDocument file.
Insert an annotation, at the position defined by the regex (before, after, content) or by positionnal argument (position). If content is provided, the annotation covers the full content regex. Else, the annotation is positionned either ‘before’ or ‘after’ provided regex.
If content is an odf element (ie: paragraph, span, ...), the full inner content is covered by the annotation (of the position just after if content is a single empty tag).
If content/before or after exists (regex) and return a group of matching positions, the position value is the index of matching place to use.
annotation_element can contain a previously created annotation, else the annotation is created from the body, creator and optional date (current date by default).
Arguments:
annotation_element – annotation element or name
before – unicode regular expression or None
after – unicode regular expression or None
content – unicode regular expression or None, or odf_element
position – int or tuple of int
body – unicode or odf_element
creator – unicode
date – datetime
Insert an annotation end tag for an existing annotation. If some end tag already exists, replace it. Annotation end tag is set at the position defined by the regex (before or after).
If content/before or after (regex) returns a group of matching positions, the position value is the index of matching place to use.
Arguments:
annotation_element – annotation element (mandatory)
before – unicode regular expression or None
after – unicode regular expression or None
position – int
Create and Insert a reference to a content marked by a reference mark. The odf_reference element (<text:reference-ref>) represents a field that references a <text:reference-mark-start> or <text:reference-mark> element. Its text:reference-format attribute specifies what is displayed from the referenced element. Default is ‘page’ Actual content is not automatically updated except for the ‘text’ format.
Name is mandatory and should represent an existing reference mark of the document. The ref_format is the type of formt reference : default is ‘page’. The reference is inserted the position defined by the regex (before/after), or by positionnal argument (position). If ‘display’ is provided, it will be used as the text value for the reference. If after is an odf element, the reference is inserted as first child of this element.
Arguments:
name – unicode
- ref_format – one of : ‘chapter’, ‘direction’, ‘page’, ‘text’,
- ‘caption’, ‘category-and-value’, ‘value’, ‘number’, ‘number-all-superior’, ‘number-no-superior’
before – unicode regular expression or None
after – unicode regular expression or odf element or None
position – int
display – unicode or None
Send back a copy of the element, the sub_links (not a clone) removed.
Arguments:
links – odf_link or list of odf_link
Send back a copy of the element, without links tags.
Send back a copy of the element, the spans (not a clone) removed.
Arguments:
spans – odf_element or list of odf_element
Send back a copy of the element, without span styles. If keep_heading is True (default), the first level heading style is left unchanged.
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 to the provided url from text content matching the regex OR the positional arguments offset and length.
(match, tail: provided by decorator)
Arguments:
url – unicode
regex – unicode regular expression
offset – int
length – int
Insert a reference mark, at the position defined by the regex (before, after, content) or by positionnal argument (position). If content is provided, the annotation covers the full range content regex (instances of odf_reference_mark_start and odf_reference_mark_end are created). Else, an instance of odf_reference_mark is positionned either ‘before’ or ‘after’ provided regex.
If content is an odf element (ie: paragraph, span, ...), the full inner content is referenced (of the position just after if content is a single empty tag).
If content/before or after exists (regex) and return a group of matching positions, the position value is the index of matching place to use.
Name is mandatory and shall be unique in the document for the preference mark range.
Arguments:
name – unicode
before – unicode regular expression or None
after – unicode regular expression or None, or odf_element
content – unicode regular expression or None, or odf_element
position – int or tuple of int
Return: the created reference or reference start
Insert/move a reference_mark_end for an existing reference mark. If some end tag already exists, replace it. Reference tag is set at the position defined by the regex (before or after).
If content/before or after (regex) returns a group of matching positions, the position value is the index of matching place to use.
Arguments:
reference_mark – reference element (mandatory)
before – unicode regular expression or None
after – unicode regular expression or None
position – int
Apply the given style to text content matching the regex OR the positional arguments offset and length.
(match, tail: provided by decorator)
Arguments:
style – style element or name
regex – unicode regular expression
offset – int
length – int
Bases: lpod.paragraph.odf_paragraph
Create a paragraph element of the given style containing the optional given text.
Arguments:
text – unicode or odf_element
style – unicode
Return: odf_element