RichText
Overview
RichText is a class in Aspose.Note for Python.
Inherits from: Node.
RichText.Append(text, style) adds the supplied text with the given style to the end of the rich‑text object and returns the same RichText instance for chaining.
RichText is the primary text-bearing node in the OneNote document tree. It holds a sequence of TextRun children, each with its own character formatting (TextStyle). The concatenated Text property provides the plain-text content of the node. Rich text nodes may carry NoteTag objects for task or status tags. To extract all text from a document, call document.GetChildNodes(RichText) and join the .Text values.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
Text | str | Read | Returns the concatenated plain text of the RichText |
TextRuns | list[TextRun] | Read | Provides a list of TextRun objects representing styled segments of the RichText |
ParagraphStyle | ParagraphStyle | Read | Gets or sets the ParagraphStyle applied to the RichText |
Tags | list[NoteTag] | Read | Returns a list of NoteTag objects attached to the RichText |
Length | int | Read | Returns the number of characters contained in the RichText |
Alignment | HorizontalAlignment | None | Read | Gets or sets the horizontal alignment of the RichText paragraph; may be None |
IsTitleText | bool | Read | Indicates whether the RichText is used as a title text element |
IsTitleDate | bool | Read | Indicates whether the RichText represents a title date |
IsTitleTime | bool | Read | Indicates whether the RichText represents a title time |
Methods
| Signature | Description |
|---|---|
__init__(Text: str, TextRuns: list[TextRun] | None, ParagraphStyle: ParagraphStyle | None, Alignment: HorizontalAlignment | None, Tags: list[NoteTag] | None, LastModifiedTime: datetime | None, SpaceBefore: float | None, SpaceAfter: float | None, LineSpacing: float | None) | |
Append(text: str, style: TextStyle | None) → RichText | Adds the supplied text with the given style to the end of the rich‑text object and returns the same RichText instance for chaining |
AppendFront(text: str, style: TextStyle | None) → RichText | |
Clear() → RichText | Removes all content from the RichText and returns the RichText |
GetEnumerator() → Iterator[str] | Returns an iterator over the characters of the RichText |
IndexOf(value: str, startIndex: int, count: int | None, comparison: str | None) → int | Returns the zero‑based index of a value within a range, optionally using a comparison mode |
Insert(index: int, text: str, style: TextStyle | None) → RichText | Inserts text with an optional style at the specified index and returns the RichText |
Remove(start: int, count: int | None) → RichText | Deletes a number of characters starting at a position and returns the RichText |
Replace(old_value: str, new_value: str, style: TextStyle | None) → RichText | Substitutes all occurrences of old_value with new_value, applying an optional style, and returns the RichText |
Trim() → RichText | Removes leading and trailing whitespace from the RichText and returns the RichText |
TrimStart() → RichText | |
TrimEnd() → RichText |