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

NameTypeAccessDescription
TextstrReadReturns the concatenated plain text of the RichText
TextRunslist[TextRun]ReadProvides a list of TextRun objects representing styled segments of the RichText
ParagraphStyleParagraphStyleReadGets or sets the ParagraphStyle applied to the RichText
Tagslist[NoteTag]ReadReturns a list of NoteTag objects attached to the RichText
LengthintReadReturns the number of characters contained in the RichText
AlignmentHorizontalAlignment | NoneReadGets or sets the horizontal alignment of the RichText paragraph; may be None
IsTitleTextboolReadIndicates whether the RichText is used as a title text element
IsTitleDateboolReadIndicates whether the RichText represents a title date
IsTitleTimeboolReadIndicates whether the RichText represents a title time

Methods

SignatureDescription
__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)RichTextAdds 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()RichTextRemoves 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)intReturns the zero‑based index of a value within a range, optionally using a comparison mode
Insert(index: int, text: str, style: TextStyle | None)RichTextInserts text with an optional style at the specified index and returns the RichText
Remove(start: int, count: int | None)RichTextDeletes a number of characters starting at a position and returns the RichText
Replace(old_value: str, new_value: str, style: TextStyle | None)RichTextSubstitutes all occurrences of old_value with new_value, applying an optional style, and returns the RichText
Trim()RichTextRemoves leading and trailing whitespace from the RichText and returns the RichText
TrimStart()RichText
TrimEnd()RichText